def to_integral

bend-collections-laws-crypto@1.0.0.0 · spec/math/f64.bend:340

import bend-collections-laws-crypto@1.0.0.0/spec/math/f64.bend as F64
import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/f64.bend as F

340# NaN gives NaN, an infinity or a value of at least 2^52 is already integral,
341# anything else is its integer (with the sign of x, so -0.5 goes to -0 under
342# trunc, ceil and round)
343def to_integral(m: F.RMode, +x: F.F64) -> F.F64:
344  pick(F.F64, is_nan(x), qnan(), pick(F.F64, Bool.or(is_inf(x), Nat.is_le(zb(), xexp(x))), x, round(sign(x), integral(m, sign(x), mant(x), Nat.sub(zb(), xexp(x))), zb())))

Uses (15)

Used by (8)