def rp_fin
import bend-collections@1.0.0.0/src/math/f64.bend as F64import Base
import bend-collections@1.0.0.0/src/math/u64.bend as W
import bend-collections@1.0.0.0/src/math/w64.bend as X
137# sig has its top bit at 62 and e is the plain exponent (0 <= e <= 0x7FD):
138# add half an ulp of the kept 53 bits, shift, and clear bit 0 on a tie
139def rp_fin(+s: Bool, +e: Nat, +sig: W.U64) -> F64:
140 rp_fin2(s, e, X.shr(X.add(sig, W.U64{512, 0}), 10n), U32.is_eq(U32.and(X.lo(sig), 1023), 512))