[Cfp-interest 2256] printf and rounding recommendation
Vincent Lefevre
vincent at vinc17.net
Thu Nov 4 02:51:37 PDT 2021
In the current C2x draft N2731, 7.21.6.1 The fprintf function:
Recommended practice
[...]
13 [...] If the number of significant decimal digits is more than M
but the source value is exactly representable with M digits, then
the result should be an exact representation with trailing zeros.
Otherwise, the source value is bounded by two adjacent decimal
strings L < U, both having M significant digits; the value of
the resultant decimal string D should satisfy L ≤ D ≤ U, with the
extra stipulation that the error should have a correct sign for
the current rounding direction.
In the case of directed rounding, this means that correct rounding is
recommended (in both cases: exact[*] or not). But this is not the case
for rounding-to-nearest. This is surprising.
[*] In directed rounding, this involves the Table Maker's Dilemma if
one ensures the correct direction (i.e. that the error has a correct
sign).
--
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
More information about the Cfp-interest
mailing list