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.

Example

Local

1
SELECT evm_clamp(7::UINT256, 10::UINT256, 5::UINT256)::VARCHAR AS result;
2
-- => [{"result":"10"}]
Notebook ready in readonly mode.

API reference

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

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.

Related functions

Category and tags

Category
EVM utilities
Tag
Types
Tag
EVM