evm_set_bits

Positions of one bits in a 256-bit unsigned EVM word, ascending from bit 0. Zero gives []; UINT256_MAX gives 0 through 255. NULL propagates. A list comprehension turns a bitmap word into its members, e.g. initialized ticks of a tick bitmap word.

Scalar function TypesEVM

Example

Runs locally

-- The initialized ticks of tick-bitmap word 2 at tick spacing 10: tick = (word * 256 + bit) * spacing
SELECT [(2 * 256 + b) * 10 FOR b IN evm_set_bits('0x8000000000000000000000000000000000000000000000000000000000000041'::UINT256)] AS ticks;
-- => [{"ticks":[5120,5180,7670]}]

API reference

evm_set_bits(UINT256) #

Ascending set-bit positions of a UINT256 as UTINYINT[].

Inputs

Name Type Use
x UINT256

UINT256 word whose one bits are listed.

required positional

Returns

Name Type
positions UTINYINT[]

Set-bit positions. UTINYINT[], distinct, ascending, in [0, 255]; [] for zero; NULL for NULL. Length is evm_bit_count(x).