Standard library / std::bits

std::bits

std::bits is the standard bit-manipulation and byte-order helper module.

Full reference: bits.

Supported forms#

Defined in std/bits.slk:

Example#

import std::bits;

fn main () -> int {
  let v: u32 = 1;
  let r: u32 = std::bits::rotl_u32(v, 5);
  if r != ((1 as u32) << 5) {
    return 1;
  }

  if std::bits::popcount_u32(r) != 1 {
    return 2;
  }

  return 0;
}

Source repository · Edit this page · View Markdown