BitMath
Last updated
Last updated
Helper contract used for bit calculations
Returns the index of the closest bit on the right of x that is non null
Parameters
x
uint256
The value as a uint256
bit
uint8
The index of the bit to start searching at
Returns
id
uint256
The index of the closest non null bit on the right of x. If there is no closest bit, it returns max(uint256)
Returns the index of the closest bit on the left of x that is non null
Parameters
x
uint256
The value as a uint256
bit
uint8
The index of the bit to start searching at
Returns
id
uint256
The index of the closest non null bit on the left of x. If there is no closest bit, it returns max(uint256)
Returns the index of the most significant bit of x This function returns 0 if x is 0
Parameters
x
uint256
The value as a uint256
Returns
msb
uint8
The index of the most significant bit of x
Returns the index of the least significant bit of x This function returns 255 if x is 0
Parameters
x
uint256
The value as a uint256
Returns
lsb
uint8
The index of the least significant bit of x