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.

Example

Local

1
SELECT evm_sar(1::BIGINT, (-3)::INT256)::VARCHAR AS result;
2
-- => [{"result":"-2"}]
Notebook ready in readonly mode.

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

evm_sar(BIGINT, INT256) #

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

Inputs

Name Type Use
shift BIGINT

Non-negative BIGINT bit count.

required positional
x INT256

Two's-complement INT256 word.

required positional

Returns

Name Type
result INT256

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

Category and tags

Category
EVM utilities
Tag
Types
Tag
EVM