Expand description
Number formats, precisions, and rounding modes.
mpmfnum is a numbers library for emulation various number formats,
at multiple precisions with many rounding modes. Hence its name
“Multi-Precision, Multi-Format” (MPMF). Unlike other number libraries like
BigInt or
Rug (MPFR), this library emphasizes
a clean abstraction of various computer number systems rather than
high-performance computation.
This library embraces design principles found in the FPCore standard.
Most importantly, numerical programs need only be specified by
(i) real-number mathematical operations and (ii) rounding.
Number formats, e.g., double or float, are not first-class,
as in most programming languages.
Rather, formats are side effects of rounding and should
be de-emphasized or eliminated entirely.
Furthermore, all values within a numerical program should be
viewed as (extended) real numbers.
These design principles are reflected in the two primary traits of this library:
Realis an extended real value;RoundingContextis a rounding operation onRealvalues.
For implementation purposes, we restrict any Real value to be of
the form (-1)^s * c * 2^exp where s is 0 or 1, c is a
non-negative integer, and exp is an integer.
Implementations of RoundingContext may support any of
the numerous operations (as traits) found under crate::ops.
Operations provided by this library are correctly rounded.
mpmfnum supports various number systems through implementations of RoundingContext:
RealContextperforms no rounding, that is, the operation is exact,RFloatContextrounds aRealvalue to an arbitrary-precision, floating-point numbers with unbounded exponent,FloatContextrounds aRealvalue to a fixed-precision, floating-point numbers with unbounded exponent,IEEE754Contextrounds aRealvalue to a floating-point number as described by the IEEE 754 standard,FixedContextrounds aRealvalue to a fixed-point numbers,PositContextrounds aRealvalue to a posit number as described by the Posit standard.
Re-exports§
pub use crate::rfloat::RFloat;
Modules§
- fixed
- Multiple flavors of fixed-point numbers.
- float
- Fixed-precision, floating-pont numbers with unbounded exponent.
- ieee754
- Floating-point numbers as described in the IEEE 754-2019 standard.
- mpfr
- Round-to-odd arithmetic using MPFR.
- ops
- Rounded mathematical operations.
- posit
- “Posit” numbers as described in the 2022 Posit Standard.
- real
- Exact arithmetic.
- rfloat
- Floating-point numbers with unbounded significand and exponent.
Macros§
- context_
alias - Similar to the unstable
trait_aliasfeature. Associates a groups a set of traits into a single named trait.
Structs§
Enums§
- Rounding
Direction - Directed rounding.
- Rounding
Mode - Rounding modes for rounding contexts.
Traits§
- Real
- Universal trait for extended real numbers.
- Rounding
Context - Universal trait for rounding contexts.