|
Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
|
Namespaces | |
| namespace | detail |
Classes | |
| struct | decimal_fp |
Functions | |
| decimal_fp | to_decimal (uint64_t mantissa, int exponent, unsigned mantissa_width) |
| Convert a binary floating-point value to its shortest decimal representation. | |
| decimal_fp | float_to_decimal (float value) |
| Convenience: convert a native float to shortest decimal. | |
| decimal_fp | double_to_decimal (double value) |
| Convenience: convert a native double to shortest decimal. | |
|
inline |
Convenience: convert a native double to shortest decimal.
Preconditions: value must be finite, positive, and non-zero. Zero, NaN, infinity, and negative values return {0, 0}.
|
inline |
Convenience: convert a native float to shortest decimal.
Preconditions: value must be finite, positive, and non-zero. Zero, NaN, infinity, and negative values return {0, 0}.
|
inline |
Convert a binary floating-point value to its shortest decimal representation.
| mantissa | Full binary significand (with implicit 1 bit set for normals) |
| exponent | Binary exponent such that value = mantissa * 2^exponent |
| mantissa_width | Total number of significand bits (including hidden bit) |
Preconditions: mantissa > 0 (value must be finite and positive) The caller handles sign, zero, NaN, and infinity.