← Standard library

Bits

static class Bits
import Bits from Wax;

Width-aware bit operations for integral types. Signed inputs are treated as their fixed-width bit patterns except that IsPowerOfTwo requires a positive value. Results retain the input width.

Bits.wax:6

Inherits from object. Follow these links for inherited members.

Members

CountLeadingZerosmethod

public static fn CountLeadingZeros<T>(T value) : int32 where T is integral

Counts zero bits from the most significant end. Zero returns the full bit width.

Bits.wax:31

CountTrailingZerosmethod

public static fn CountTrailingZeros<T>(T value) : int32 where T is integral

Counts zero bits from the least significant end. Zero returns the full bit width.

Bits.wax:49

PopCountmethod

public static fn PopCount<T>(T value) : int32 where T is integral

Counts set bits in the input width, including the sign bit of signed values.

Bits.wax:66

RotateLeftmethod

public static fn RotateLeft<T>(T value, int32 amount) : T where T is integral

Rotates bits left, wrapping displaced bits to the other end. The amount is reduced modulo the type width, including negative amounts.

Bits.wax:80

RotateRightmethod

public static fn RotateRight<T>(T value, int32 amount) : T where T is integral

Rotates bits right, wrapping displaced bits to the other end. The amount is reduced modulo the type width, including negative amounts.

Bits.wax:96

ByteSwapmethod

public static fn ByteSwap<T>(T value) : T where T is integral

Reverses byte order within the integral value; an 8-bit value is unchanged.

Bits.wax:111

IsPowerOfTwomethod

public static fn IsPowerOfTwo<T>(T value) : bool where T is integral

Tests for exactly one set bit and a positive numeric value. Zero and negative signed values return false.

Bits.wax:127