Port of LLVM’s APFloat software floating-point implementation from the following C++ sources (please update commit hash when backporting): https://github.com/llvm-mirror/llvm/tree/23efab2bbd424ed13495a420ad8641cb2c6c28f9
The port contains no unsafe code, global state, or side-effects in general, and the only allocations are in the conversion to/from decimal strings.
Most of the API and the testcases are intact in some form or another,
with some ergonomic changes, such as idiomatic short names, returning
new values instead of mutating the receiver, and having separate method
variants that take a non-default rounding mode (with the suffix
Comments have been preserved where possible, only slightly adapted.
Instead of keeping a pointer to a configuration struct and inspecting it
dynamically on every operation, types (e.g.,
ieee::Semantics) and associated constants are employed for
increased type safety and performance.
On-heap bigints are replaced everywhere (except in decimal conversion),
with short arrays of
type Limb = u128 elements (instead of
This allows fitting the largest supported significands in one integer
ppc::Fallback use slightly less than 128 bits).
All of the functions in the
ieee::sig module operate on slices.
This API is completely unstable and subject to change.
IEEE-754R 7: Default exception handling.
Category of internally-represented number.
IEEE-754R 4.3: Rounding-direction attributes.
A self-contained host- and target-independent arbitrary-precision floating-point software implementation.
A signed type to represent a floating point number’s unbiased exponent.