The library provides consistent, human-readable formatting across decimal32 · decimal64 · decimal128 Display is available via: std::string conversion , operator<< (ostream) std::format and low-level BID helpers (display_bidXX, print)
Low-level formatting operates directly on raw BID values:
math::bid::display_bid32(uint32_t)
math::bid::display_bid64(uint64_t)
math::bid::display_bid128(BID_UINT128)
Example:
Numbers are rendered in normalized decimal form:
| Internal | Output |
|---|---|
(12345, -2) |
"123.45" |
(5, -3) |
"0.005" |
(42, 3) |
"4200" |
- Negative values include
- - No scientific notation for
decimal32/decimal64 decimal128is normalized to fixed notation
Zero is canonically normalized:
- Sign and exponent are ignored - All representations collapse to"0"
| Value | Output |
|---|---|
| NaN | "nan" |
| +∞ | "+inf" |
| -∞ | "-inf" |
Example:
Internally, decimal128 may use scientific form:
Display is normalized:
- No
Enotation in output - Precision: 34 significant digits
- Inputs exceeding precision are rounded
This reflects: \(\text{binary float} \neq \text{exact decimal value}\)
- Full decimal expansion is preserved
- No “pretty-printing” heuristics
Internal helper used by all display functions:
Behavior:
- Places decimal point according to exponent
- Pads with zeros
- Preserves trailing zeros
| Area | Note |
|---|---|
| Float inputs | May expand (e.g. "0.1000000") |
| Zero normalization | Always rendered as "0" |
| Invalid input | Always mapped to NaN |
| Scientific Notation | Exponent is off by 1, see: test/thirdparty.cpp |