# try_sub

Subtracts two UINT256 values. Arithmetic underflow produces NULL; independently, ordinary scalar NULL propagation produces NULL when either input is NULL.

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

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

Subtracts two UINT256 values. Arithmetic underflow produces NULL; independently, ordinary scalar NULL propagation produces NULL when either input is NULL.

## Overload 1: try_sub(UINT256, UINT256)

```sql
try_sub(UINT256, UINT256)
```

Returns a - b when a >= b, otherwise NULL.

- 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

- `a` (UINT256; required; positional) — UINT256 value from which b is subtracted.
- `b` (UINT256; required; positional) — UINT256 value subtracted from a.

### Returns

Checked difference

UINT256 difference, or NULL for arithmetic underflow or an input NULL.

- `difference` (UINT256)

Checked difference. UINT256 difference, or NULL for arithmetic underflow or an input NULL.

### Examples

_Local SQL · Local_

```sql
SELECT try_sub(5::UINT256, 8::UINT256)::VARCHAR AS result;
-- => [{"result":null}]
```

## Related functions

- [evm_addmod](/docs/functions/evm_addmod.md) — See Also
- [evm_mulmod](/docs/functions/evm_mulmod.md) — See Also
- [muldiv](/docs/functions/muldiv.md) — See Also
