# 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.

Canonical HTML: <https://determica.com/docs/functions/evm_set_bits>

- Kind: scalar function
- Category: [EVM utilities](/docs/category/evm-utilities.md)
- Tags: Types, EVM

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.

## Overload 1: evm_set_bits(UINT256)

```sql
evm_set_bits(UINT256)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `x` (UINT256; required; positional) — UINT256 word whose one bits are listed.

### Returns

Set-bit positions

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

- `positions` (UTINYINT[])

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

### Examples

_Local SQL · Local_

```sql
-- 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]}]
```

## Related functions

- [evm_bit_count](/docs/functions/evm_bit_count.md) — See Also
- [evm_ctz](/docs/functions/evm_ctz.md) — See Also
- [clmm_swap_x96](/docs/functions/clmm_swap_x96.md) — Usually After
