Define TS 18661-1 CR_DECIMAL_DIG in <float.h>.
commitcb19a0da15644d08411275996c3273eeb3b1ea1c
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 19 Sep 2016 21:53:30 +0000 (19 21:53 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 19 Sep 2016 21:53:30 +0000 (19 21:53 +0000)
treeecf2e5e975a48025cf658592f3b195f1d7698743
parent9b5c49ef97e63cc63f1ffa13baf771368105ebe2
Define TS 18661-1 CR_DECIMAL_DIG in <float.h>.

TS 18661-1 defines a macro CR_DECIMAL_DIG in <float.h>, for the number
of decimal digits for which conversions between decimal character
strings and (IEEE) binary formats, in both directions, are correctly
rounded.  This patch implements support for this macro in GCC's
<float.h>.

The definition __UINTMAX_MAX__ is the right one for GCC's conversions
of floating constants, since I made those use MPFR to make them
correctly rounding.  The macro also covers standard library functions
such as strtod and printf.  The definition is also correct for current
glibc.  If any targets' libcs support correct rounding in a way that
conforms to TS 18661-1 with a smaller value of CR_DECIMAL_DIG, making
<float.h> reflect that could not be done in isolation without changes
to the interpretation of floating constants as well, since a smaller
CR_DECIMAL_DIG requires double rounding of floating constants (first
to CR_DECIMAL_DIG decimal digits, then to the desired binary format).

Boostrapped with no regressions on x86_64-pc-linux-gnu.

gcc:
* ginclude/float.h [__STDC_WANT_IEC_60559_BFP_EXT__]
(CR_DECIMAL_DIG): New macro.

gcc/testsuite:
* gcc.dg/cr-decimal-dig-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240249 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/ginclude/float.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cr-decimal-dig-1.c [new file with mode: 0644]