Skip to main content

BitMath

Table of contents​

Constructors​

Methods​

Constructors​

constructor​

• new BitMath(): BitMath

Returns​

BitMath

Methods​

closestBit​

▸ closestBit(_integer, _bit, _rightSide): Result<u8>

Returns the closest non-zero bit of integer to the right (of left) of the bit bits that is not bit

Parameters​

NameTypeDescription
_integeru256The integer as a u256
_bitu8The bit index
_rightSideboolWhether we're searching in the right side of the tree (true) or the left side (false)

Returns​

Result<u8>

The index of the closest non-zero bit.

Defined in​

assembly/libraries/BitMath.ts:35


closestBitLeft​

▸ closestBitLeft(x, bit): Result<u8>

Returns the index of the closest bit on the left of x that is non null

Parameters​

NameTypeDescription
xu256The value as a u256
biti32The index of the bit to start searching at

Returns​

Result<u8>

The index of the closest non null bit on the left of x.

Defined in​

assembly/libraries/BitMath.ts:62


closestBitRight​

▸ closestBitRight(x, bit): Result<u8>

Returns the index of the closest bit on the right of x that is non null

Parameters​

NameTypeDescription
xu256The value as a u256
biti32The index of the bit to start searching at

Returns​

Result<u8>

The index of the closest non null bit on the right of x.

Defined in​

assembly/libraries/BitMath.ts:47


leastSignificantBit​

▸ leastSignificantBit(x): u8

Returns the index of the least significant set bit

Parameters​

NameType
xu256

Returns​

u8

The index of the least significant bit of x

Defined in​

assembly/libraries/BitMath.ts:81


mostSignificantBit​

▸ mostSignificantBit(x): u8

Returns the index of the most significant set bit

Parameters​

NameType
xu256

Returns​

u8

The index of the most significant bit of x

Defined in​

assembly/libraries/BitMath.ts:74


significantBit​

▸ significantBit(x, most): u8

Returns the most (true) or least (false) significant bit index

Parameters​

NameType
xu256
mostbool

Returns​

u8

The index of the most (or least) significant bit

Defined in​

assembly/libraries/BitMath.ts:90