def to_integral
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/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)
- bend-collections-laws-crypto@1.0.0.0/spec/math/f64:modf
- bend-collections-laws-crypto@1.0.0.0/spec/math/f64:Ceil.value
- bend-collections-laws-crypto@1.0.0.0/spec/math/f64:CeilU64.value
- bend-collections-laws-crypto@1.0.0.0/spec/math/f64:Floor.value
- bend-collections-laws-crypto@1.0.0.0/spec/math/f64:FloorU64.value
- …