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.

Example

Local

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

API reference

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

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.

Related functions

Category and tags

Category
EVM utilities
Tag
Types
Tag
EVM