niedz., 12 paź 2025 o 16:24 Matt Borland <matt@mattborland.com> napisał(a):
On Sunday, October 12th, 2025 at 3:25 PM, Michel Morin via Boost < boost@lists.boost.org> wrote:
Andrzej Krzemienski wrote:
Hashing and equality aside, do users need to know which cohort-member is used for representation while formatting the value? Why would you like to know this?
The decarith ("decimal arithmetic specification"), at https://speleotrove.com/decimal/, discusses this in Appendix B "Design concepts":
For example, people expect trailing zeros to be indicated conventionally in a result: the sum 1.57 + 2.03 is expected to result in 3.60, not 3.6; however, if the positional information has been lost during the operation it is no longer possible to show the expected result. For some applications the loss of trailing zeros is materially significant.
IEEE 754 also requires this (IEEE 754-2019, Clause 5.12.2). My own use case is debugging.
Precision and cohort retention are mutually exclusive so to_chars could be extended with something to the effect of:
enum class quantum_retention { on, off }
to_chars_result to_chars(char* first, char* last, Decimal value, chars_format fmt, quantum_retention retention_mode);
Then the D format parameter could be an inherited decision from C, and be used with {fmt}/<format> since the quoted clause specifies this as a language level decision for implementation.
Are there also IEEE 754 requirements or recommendations on what exponent a resulting decimal should have when you are adding decimals with different exponents? Regards, &rzej;
Matt