mir.bitop

This module contains a collection of bit-level operations.

Members

Functions

bt
auto bt(Field p, size_t bitnum)

Tests the bit.

bta
auto bta(Field p, size_t bitnum, bool value)

Tests and assign the bit.

btc
auto btc(Field p, size_t bitnum)

Tests and complements the bit.

btr
auto btr(Field p, size_t bitnum)

Tests and resets (sets to 0) the bit.

bts
auto bts(Field p, size_t bitnum)

Tests and sets the bit.

ctlz
T ctlz(T src)

The 'ctlz' family of intrinsic functions counts the number of leading zeros in a variable. Result is undefined if the argument is zero.

ctlzp
T ctlzp(T src)

The 'ctlzp' family of intrinsic functions counts the number of leading zeros in a variable. Result is properly defined if the argument is zero.

ctpop
T ctpop(T src)

The 'ctpop' family of intrinsics counts the number of bits set in a value.

cttz
T cttz(T src)

The 'cttz' family of intrinsic functions counts the number of trailing zeros. Result is undefined if the argument is zero.

cttzp
T cttzp(T src)

The 'cttz' family of intrinsic functions counts the number of trailing zeros. Result is properly defined if the argument is zero.

nLeadingBitsToCount
T nLeadingBitsToCount(T value, T popcnt)
nTrailingBitsToCount
T nTrailingBitsToCount(T value, T popcnt)

Variables

bitElemShift
enum uint bitElemShift(T : ubyte);
enum uint bitElemShift(T : byte);
enum uint bitElemShift(T : ushort);
enum uint bitElemShift(T : short);
enum uint bitElemShift(T : uint);
enum uint bitElemShift(T : int);
enum uint bitElemShift(T : ulong);
enum uint bitElemShift(T : long);
enum uint bitElemShift(T : ucent);
enum uint bitElemShift(T : cent);

Right shift vallue for bit index to get element's index (5 for uint).

bitShiftMask
enum uint bitShiftMask(T : ubyte);
enum uint bitShiftMask(T : byte);
enum uint bitShiftMask(T : ushort);
enum uint bitShiftMask(T : short);
enum uint bitShiftMask(T : uint);
enum uint bitShiftMask(T : int);
enum uint bitShiftMask(T : ulong);
enum uint bitShiftMask(T : long);
enum uint bitShiftMask(T : ucent);
enum uint bitShiftMask(T : cent);

Bit mask for bit index to get element's bit shift (31 for uint).

Meta

Authors

Ilya Yaroshenko, Phobos & LDC Authors (original Phobos unittests, docs, conventions).