def sq_rem
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
449# N - S0^2 = a - b for a = u 2^32, b = q^2: the root is S0 when b <= a
450def sq_rem(+e: Nat, +s0: W.U64, +a: W.U64, +b: W.U64, ge: Bool) -> F64:
451 match ge:
452 case True{}:
453 sq_fin(e, s0, Bool.not(X.eq(a, b)))
454 case False{}:
455 sq_neg(e, s0, X.sub(b, a))