# INT256

256-bit signed EVM integer stored as a 32-byte two's-complement ABI word. Decimal string casts parse exact numeric values; 0x-prefixed strings parse raw bytes. VARCHAR output is decimal for display; use sort_key for signed ordering and BYTES/BYTES32 casts for raw ABI/storage boundaries.

Canonical HTML: <https://determica.com/docs/types/int256>

- Family: Signed integer
- Physical type: BLOB

256-bit signed EVM integer stored as a 32-byte two's-complement ABI word. Decimal string casts parse exact numeric values; 0x-prefixed strings parse raw bytes. VARCHAR output is decimal for display; use sort_key for signed ordering and BYTES/BYTES32 casts for raw ABI/storage boundaries.

## Used by functions

### Input and output

- [evm_sar](/docs/functions/evm_sar.md) — Implements EVM SAR over a two's-complement INT256 word: right shifts with sign-bit fill. Counts at least 256 return -1 for negative x and 0 otherwise. Negative SQL BIGINT counts throw Invalid Input Error: Shift amount must be non-negative. NULL input propagates to NULL.
- [muldiv](/docs/functions/muldiv.md) — x * y / z with a 512-bit product: no overflow before division. UINT256 rounds down, INT256 truncates toward zero, unless a rounding mode is given. Errors when z is zero or result does not fit its type. NULL propagates. Native integer arguments fit both forms: cast them to UINT256 or INT256.

### Accepted as input

- [clmm_swap_step_x96](/docs/functions/clmm_swap_step_x96.md) — Computes one Uniswap v4 SwapMath-compatible price-range step. Negative amount_remaining means exact input; non-negative means exact output. Direction is inferred from current versus target. Hooks, dynamic fee resolution, tick-crossing liquidity changes, multi-word iteration, slippage, routing, and calldata are outside this deterministic helper. The five-argument overload uses Uniswap v4's 1,000,000 fee denominator.
- [clmm_swap_x96](/docs/functions/clmm_swap_x96.md) — Exact swap across initialized ticks, as the Uniswap v3 and v4 swap loop: each step ends at the next listed tick or the tick-bitmap word edge (256 x tick_spacing), whichever is first, with clmm_swap_step_x96 math; crossing adds liquidity_net moving up, subtracts it moving down. Stops at the amount, price limit or list end; never assumes liquidity past listed ticks. Offline: caller reads state and ticks. No hooks, dynamic fees or protocol fee split. List sorted once per call.
- [evm_abi_word](/docs/functions/evm_abi_word.md) — Encodes an ADDRESS, BYTES32, BOOLEAN, or integer as one 32-byte Solidity ABI word. ADDRESS and unsigned integer values are left-padded with zeros. Signed integers are sign-extended in two's-complement form; BOOLEAN uses 0 or 1. BYTES32 values are copied unchanged.
- [evm_sign](/docs/functions/evm_sign.md) — Returns -1 for a negative two's-complement INT256 value, 0 for zero, and 1 for a positive value. NULL input propagates to NULL.
- [fixed_exp](/docs/functions/fixed_exp.md) — Computes e^(x / 1e18) * 1e18 for an 18-decimal fixed-point (WAD) exponent, with integer arithmetic only. NULL propagates; an exponent outside [-41e18, 130e18] errors. Results equal, digit for digit, those of the LogExpMath library that Balancer V2 and Pendle V2 contracts use, so a query recomputes an on-chain rate exactly. Accuracy: within 1e-17 relative for results of 1e17 or more; a few wei near 1e18 (exp(1e18) is 2718281828459045235); a tiny result keeps few digits (exp(-41e18) is 1, true 1.56).
- [format_ether](/docs/functions/format_ether.md) — Human-readable helper for wei balances. Equivalent to format_units(amount, 18). Returns VARCHAR without introducing floating point conversion.
- [format_units](/docs/functions/format_units.md) — Scales raw EVM integer balances by 10^decimals and returns a VARCHAR string representation. No floating point conversion is introduced. The default decimal scale is 18. INT256 inputs preserve signed values, and trailing fractional zeros are trimmed from the formatted string.
- [length](/docs/functions/length.md) — Returns the number of bytes in a BLOB or BLOB-backed EVM value such as ADDRESS, BYTES32, UINT256, or INT256.
- [sort_key](/docs/functions/sort_key.md) — Converts INT256/INT512/UINT256/UINT512 to a sortable BLOB for use in ORDER BY. Necessary because Determica's default BLOB ordering doesn't handle signed integers correctly. Use sort_key only inside ORDER BY or comparison-key workflows; it is not a human-readable number conversion, hash, or portable serialization.

### Returned as output

- [fixed_ln](/docs/functions/fixed_ln.md) — Computes ln(x / 1e18) * 1e18 for a positive 18-decimal fixed-point (WAD) value, with integer arithmetic only; arguments in (0.9e18, 1.1e18) use a 36-decimal series. NULL propagates. Results equal, digit for digit, those of the LogExpMath library that Balancer V2 and Pendle V2 contracts use, so a query recomputes an on-chain rate exactly. Accuracy: within 2 wei of the true value, on either side.
