evm_sqrt

Returns the floor integer square root of a UINT256 value using overflow-safe Newton iteration. Defined for the full UINT256 range. NULL input propagates to NULL.

Scalar function TypesEVM

Example

Runs locally

SELECT evm_sqrt(10::UINT256)::VARCHAR AS result;
-- => [{"result":"3"}]

API reference

evm_sqrt(UINT256) #

Returns the greatest UINT256 r such that r * r <= x.

Inputs

Name Type Use
x UINT256

UINT256 value in the inclusive range 0 through UINT256_MAX.

required positional

Returns

Name Type
sqrt UINT256

Floor square root. UINT256 floor(sqrt(x)), or NULL when x is NULL.