# evm_bit_count

Counts set bits in the complete 256-bit unsigned EVM word. Returns 0 for zero and 256 for UINT256_MAX. NULL input propagates to NULL.

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

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

Counts set bits in the complete 256-bit unsigned EVM word. Returns 0 for zero and 256 for UINT256_MAX. NULL input propagates to NULL.

## Overload 1: evm_bit_count(UINT256)

```sql
evm_bit_count(UINT256)
```

Returns the population count of a UINT256 value as BIGINT.

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

### Returns

Set-bit count

BIGINT in the inclusive range 0 through 256, or NULL for NULL input.

- `count` (BIGINT)

Set-bit count. BIGINT in the inclusive range 0 through 256, or NULL for NULL input.

### Examples

_Local SQL · Local_

```sql
SELECT evm_bit_count('0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'::UINT256) AS result;
-- => [{"result":128}]
```
