frexp
nimony/lib/std/math/frexp.nim
Freestanding (nimNativeIo, libc-free) implementations of signbit, classify, isNaN and frexp, operating directly on IEEE-754 bit patterns. The normal-value frexp bit manipulation follows Rust compiler-builtins/libm's generic/frexp.rs and FreeBSD/SunPro fdlibm's s_frexp.c; subnormals use a Nimony-specific pure-Nim scaling/recursion path instead of Rust's bit normalization. Classification and sign tests implement the IEEE-754 binary32/binary64 field definitions and the C fpclassify/signbit/isnan contracts. Sources: FreeBSD /usr/src/lib/msun/src/s_frexp.c; Rust library/compiler-builtins/libm/src/math/generic/frexp.rs. Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. Copyright (c) 2018 Jorge Aparicio (Rust compiler-builtins/libm). Developed at SunPro, a Sun Microsystems, Inc. business. Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved.
func signbit(x: T): boolReturns true if
xis negative, false otherwise.func classify(x: T): FloatClassClassifies a floating point value.
Returns
x's class as specified by theFloatClass enum<#FloatClass>_.func isNaN(x: T): boolReturns whether
xis aNaN, more efficiently than viaclassify(x) == fcNan.func frexp(x: float32): tuple[frac: float32, exp: int64]Splits
xinto a normalized fractionfracand an integral power of 2exp, such thatabs(frac) in 0.5..<1andx == frac * 2 ^ exp, except for special cases shown below.func frexp(x: float64): tuple[frac: float64, exp: int64]Splits
xinto a normalized fractionfracand an integral power of 2exp, such thatabs(frac) in 0.5..<1andx == frac * 2 ^ exp, except for special cases shown below.