Decimal datums and cohorts #
A finite datum stores a sign, an integer coefficient, and a quantum exponent:
its value is (-1)^sign * coefficient * 10^quantum. Trailing coefficient zeros
are meaningful representation information. For example, 1 × 10^0 and
10 × 10^-1 are different datums in the same cohort.
This representation layer implements IEEE 754-2019 §§3.3 and 3.5. It supplies neither decimal arithmetic nor its rounding, preferred-exponent, or exception rules.
Instances For
Text of a datum with its coefficient and quantum: plain notation such as 1.50 or 120 when
the quantum is not positive and the leading digit is at most six places after the point,
otherwise one leading digit and an e exponent, such as 1.2e4 for coefficient 12 and quantum
3. Both read back as the same coefficient and quantum. Infinities print as inf and -inf, NaNs
as nan.
Instances For
Datums print with their coefficient and quantum, as display writes them.
#eval and repr show the same text, parenthesized when negative inside an argument.
Representability at the selected precision and quantum range. NaN payloads have one fewer decimal digit than finite coefficients.
Instances For
The rational value of a finite datum, or none for infinities and NaNs.
Signed zeros remain distinct datums even though both map to zero. Zero bypasses the
radix power, so its quantum does not determine the size of an intermediate integer.
Instances For
The zero shortcut preserves the usual coefficient-times-radix-power interpretation.
Cohort relation of IEEE 754-2019 §§2.1 and 3.5.1: equal value and equal sign, including the
sign of zero. Each infinity forms a singleton cohort. NaNs have no cohort. Width-specific cohorts
restrict this relation to datums satisfying Valid.