evm_clamp

Constrains x to the inclusive range [lo, hi] when lo <= hi. For compatibility, reversed bounds lo > hi return lo; reversed bounds do not describe a valid interval. NULL input propagates to NULL.

Scalar function TypesEVM

Example

Runs locally

SELECT evm_clamp(7::UINT256, 10::UINT256, 5::UINT256)::VARCHAR AS result;
-- => [{"result":"10"}]

API reference

evm_clamp(UINT256, UINT256, UINT256) #

Returns max(lo, min(hi, x)) for valid bounds; current compatibility behavior returns lo for lo > hi.

Inputs

Name Type Use
x UINT256

UINT256 value to constrain.

required positional
lo UINT256

Inclusive UINT256 lower bound.

required positional
hi UINT256

Inclusive UINT256 upper bound.

required positional

Returns

Name Type
result UINT256

Constrained value. Constrained UINT256 value, or NULL when any input is NULL.