def round

bend-lawful-stdlib@0.1.0.0 · src/float/format.bend:90

import bend-lawful-stdlib@0.1.0.0/src/float/format.bend as Format
import Base
import bend-lawful-stdlib@0.1.0.0/src/float/bin.bend as Bin

90# the float of format f nearest to (-1)^neg * m * 2^(e - 300), ties to even
91def round(f: Format, neg: Bool, +m: Bin.Bin, +e: Nat) -> Val:
92  Format{+p, emin, emax} = f
93  +t = Nat.max(Nat.sub(Nat.add(e, Bin.len(m)), p), emin)
94  round.go(Nat.add(emax, p), neg, m, e, t, Nat.is_le(t, e))

Uses (11)

Used by (3)