Decimal text roundtrips #
The character scanner recovers the full datum. Destination rounding then fixes every valid datum: preferred-cohort optimality recovers the printed quantum, and numerical exactness recovers its coefficient. This preserves more than a rational value: signed zeros, trailing coefficient zeros, and NaN diagnostics survive a format/parse roundtrip.
Projection with a representable input's own quantum preserves its full representation.
Valid decoded datums are fixed, with no flags, in every rounding mode.
Decoding the exact character spelling recovers every field, without a format restriction.
Exact output and unbounded parsing are inverses, including all NaNs and signed zeros.
Full destination-format representation roundtrip, in every rounding mode and with no flags.
Distinct datums, including members of the same cohort, have distinct exact spellings.
Every parser result is representable in its destination format, even on invalid input.
Character conversion always returns a valid destination datum, including on invalid input.
The finite parser performs exactly one destination rounding, using the written quantum.
Zero keeps its sign and uses the written quantum clamped to the destination range.
Nearest decimal parsing has half-grid error unless the destination overflows.
A finite parser result is inexact precisely when its numerical value changed.
Upward parsing returns an upper bound on the exact decimal input.
Downward parsing returns a lower bound on the exact decimal input.
Exact input selects the valid cohort member closest to the written quantum. The written coefficient and quantum need not themselves fit the destination.
Inexact parsing uses the least quantum in the result's cohort, including directed overflow.