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:14


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:41


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:26


leastSignificantBit

leastSignificantBit(x): u8

Returns the index of the least significant bit of x

Parameters

NameTypeDescription
xu256The value as a u256

Returns

u8

The index of the least significant bit of x

Defined in

assembly/libraries/BitMath.ts:96


mostSignificantBit

mostSignificantBit(x): u8

Returns the index of the most significant bit of x

Parameters

NameTypeDescription
xu256The value as a u256

Returns

u8

The index of the most significant bit of x

Defined in

assembly/libraries/BitMath.ts:54


significantBit

significantBit(_integer, _isMostSignificant): u8

Returns the most (or least) significant bit of _integer

Parameters

NameTypeDescription
_integeru256The integer
_isMostSignificantboolWhether we want the most (true) or the least (false) significant bit

Returns

u8

The index of the most (or least) significant bit

Defined in

assembly/libraries/BitMath.ts:139