# evm_sar

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.

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

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

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.

## Overload 1: evm_sar(BIGINT, INT256)

```sql
evm_sar(BIGINT, INT256)
```

Arithmetic right shift with sign fill over a two's-complement 256-bit word.

- 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

- `shift` (BIGINT; required; positional) — Non-negative BIGINT bit count.
- `x` (INT256; required; positional) — Two's-complement INT256 word.

### Returns

Arithmetic-shifted word

INT256 shifted value, sign-filled for large counts, or NULL for NULL input.

- `result` (INT256)

Arithmetic-shifted word. INT256 shifted value, sign-filled for large counts, or NULL for NULL input.

### Examples

_Local SQL · Local_

```sql
SELECT evm_sar(1::BIGINT, (-3)::INT256)::VARCHAR AS result;
-- => [{"result":"-2"}]
```
