def sig63
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
607# n with its top bit moved to bit 62 (b = bit_length(n)): shifted up when
608# b <= 63 (every runtime Nat), jammed down otherwise
609def sig63(+n: Nat, +b: Nat, fits: Bool) -> W.U64:
610 match fits:
611 case True{}:
612 X.shl(word64(n), Nat.sub(63n, b))
613 case False{}:
614 word64(jam_nat(Nat.sub(b, 63n), n))