def sq_clamp
import bend-collections-laws-math@1.0.0.0/src/math/f64.bend as F64import Base
import bend-collections-laws-math@1.0.0.0/src/math/u64.bend as W
import bend-collections-laws-math@1.0.0.0/src/math/w64.bend as X
460# q = 2^32 (r = 2 s) is taken as q = 2^32 - 1 with u = 2 s
461def sq_clamp(+e: Nat, +s: U32, +q: W.U64, +u: U32, small: Bool) -> F64:
462 match small:
463 case True{}:
464 sq_qu(e, s, X.lo(q), u)
465 case False{}:
466 sq_qu(e, s, 4294967295, U32.add(s, s))