|
| | Decimal ()=default |
| | Decimal (std::string_view text) |
| | Parses "123", "-0.001", "1.5e-7", …; throws std::invalid_argument otherwise.
|
| | Decimal (const char *text) |
| | Throws std::invalid_argument for a null pointer.
|
| | Decimal (const std::string &text) |
| | Decimal (double value) |
| | Shortest representation that round-trips the double (0.1 → "0.1").
|
| template<std::same_as< float > T> |
| | Decimal (T)=delete |
| | Rejected: a float widens to a double that is not the value it was written as (0.1f → 0.100000001490116).
|
template<std::integral T>
requires (!detail::BoolOrCharacter<T>) |
| | Decimal (T value) |
| template<detail::BoolOrCharacter T> |
| | Decimal (T)=delete |
| | bool and character types are rejected.
|
| | Decimal (const Decimal &)=default |
| Decimal & | operator= (const Decimal &)=default |
| | Decimal (Decimal &&other) noexcept |
| | A moved-from Decimal is zero (still canonical).
|
| Decimal & | operator= (Decimal &&other) noexcept |
| | ~Decimal ()=default |
| const std::string & | str () const noexcept |
| double | to_double () const |
| | The nearest double; values beyond its range become ±HUGE_VAL or ±0.0.
|
Exact decimal number, stored as its canonical plain-notation string.
Canonical form: optional -, digits, optional . and digits. Leading zeros of the integer part, trailing zeros of the fraction and -0 are normalised away ("0010.500" → "10.5").
Exactness is guaranteed for text and integer inputs only. A double already carries binary rounding, so Decimal(double) keeps the shortest text that round-trips it, not the exact value the double was meant to hold.