def round_u
import bend-collections-laws-crypto@1.0.0.0/spec/math/f64.bend as F64import Base
import bend-collections-laws-crypto@1.0.0.0/spec/lib/common.bend as C
import bend-collections-laws-crypto@1.0.0.0/src/math/f64.bend as F
174# round (-1)^s * m * 2^(x - Z): the ulp is 2^(msb - 52), but never below
175# the subnormal ulp 2^-1074
176def round_u(+s: Bool, +m: Nat, +x: Nat, +u: Nat) -> F.F64:
177 pack(s, pick(Nat, Nat.is_le(x, u), rne(m, Nat.sub(u, x)), C.shift(Nat.sub(x, u), m)), u)