def down32

bend-collections@1.0.0.0 · src/math/w64.bend:428

import bend-collections@1.0.0.0/src/math/w64.bend as W64
import Base

428# r - 1 while r * r > x: from r <= 65535 at most r steps (fuel r + 1), and
429# r * r never wraps
430def down32(fuel: Nat, +x: U32, +r: U32, over: Bool) -> U32:
431  match fuel over:
432    case 0n _:
433      r
434    case 1n+f False{}:
435      r
436    case 1n+f True{}:
437      down32(f, x, U32.sub(r, 1), U32.is_lt(x, U32.mul(U32.sub(r, 1), U32.sub(r, 1))))

Uses (6)

Used by (1)