BitMath
Table of contents
Constructors
Methods
Constructors
constructor
• new BitMath(): BitMath
Returns
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
Name | Type | Description |
---|---|---|
_integer | u256 | The integer as a u256 |
_bit | u8 | The bit index |
_rightSide | bool | Whether 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
Name | Type | Description |
---|---|---|
x | u256 | The value as a u256 |
bit | i32 | The 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
Name | Type | Description |
---|---|---|
x | u256 | The value as a u256 |
bit | i32 | The 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
Name | Type | Description |
---|---|---|
x | u256 | The 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
Name | Type | Description |
---|---|---|
x | u256 | The 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
Name | Type | Description |
---|---|---|
_integer | u256 | The integer |
_isMostSignificant | bool | Whether we want the most (true) or the least (false) significant bit |
Returns
u8
The index of the most (or least) significant bit