def rm_fix
import bend-collections-laws-crypto@1.0.0.0/src/math/f64.bend as F64import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend as W
import bend-collections-laws-crypto@1.0.0.0/src/math/w64.bend as X
1115# remainder r of divisor b at scale u, last quotient digit q: round the
1116# quotient to nearest (ties to even) by flipping to r - b
1117def rm_fix(+s: Bool, +u: Nat, +b: W.U64, +r: W.U64, +q: W.U64) -> F64:
1118 rm_pick(s, u, b, r, Bool.or(X.lt(b, X.add(r, r)), Bool.and(X.eq(X.add(r, r), b), X.odd(q))))