def isqrt32_est
import bend-collections-laws-crypto@1.0.0.0/src/math/w64.bend as W64import Base
455# floor(sqrt(x)) from any estimate r <= 65535: down while r^2 > x, then up
456# while (r + 1)^2 <= x. The F32 square root lands within 1, so both loops
457# take at most a step or two; the fuel covers any estimate, so the result
458# never depends on F32's accuracy.
459def isqrt32_est(+x: U32, +r: U32) -> U32:
460 isqrt32_fix(x, down32(1n+U32.to_nat(r), x, r, U32.is_lt(x, U32.mul(r, r))))