Bits
static class Bitsimport 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.
Inherits from object. Follow these links for inherited members.
Members
CountLeadingZerosmethod
public static fn CountLeadingZeros<T>(T value) : int32 where T is integralCounts zero bits from the most significant end. Zero returns the full bit width.
CountTrailingZerosmethod
public static fn CountTrailingZeros<T>(T value) : int32 where T is integralCounts zero bits from the least significant end. Zero returns the full bit width.
PopCountmethod
public static fn PopCount<T>(T value) : int32 where T is integralCounts set bits in the input width, including the sign bit of signed values.
RotateLeftmethod
public static fn RotateLeft<T>(T value, int32 amount) : T where T is integralRotates bits left, wrapping displaced bits to the other end. The amount is reduced modulo the type width, including negative amounts.
RotateRightmethod
public static fn RotateRight<T>(T value, int32 amount) : T where T is integralRotates bits right, wrapping displaced bits to the other end. The amount is reduced modulo the type width, including negative amounts.
ByteSwapmethod
public static fn ByteSwap<T>(T value) : T where T is integralReverses byte order within the integral value; an 8-bit value is unchanged.
IsPowerOfTwomethod
public static fn IsPowerOfTwo<T>(T value) : bool where T is integralTests for exactly one set bit and a positive numeric value. Zero and negative signed values return false.