def modf

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

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

493# (fractional part, integral part), both with the sign of x, both exact:
494# modf(-2.0) = (-0.0, -2.0), modf(inf) = (0.0, inf) (4.3)
495def modf(+x: F.F64) -> F.F64 & F.F64:
496  pickt(F.F64 & F.F64, is_nan(x), (qnan(), qnan()), pickt(F.F64 & F.F64, Bool.or(is_inf(x), Nat.is_le(zb(), xexp(x))), (zero(sign(x)), x), (round(sign(x), C.low(Nat.sub(zb(), xexp(x)), mant(x)), xexp(x)), to_integral(F.Trunc{}, x))))

Uses (19)

Used by (2)