Mail Archives: djgpp-workers/2003/08/10/16:01:14
--part1_16e.2264c067.2c67fe7c_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit
In a message dated 8/10/2003 3:30:30 PM Eastern Standard Time,
eliz AT elta DOT co DOT il writes:
> >Date: Sun, 10 Aug 2003 14:17:13 -0400
> >From: DJ Delorie <dj AT delorie DOT com>
> >
> >>Behold:
> >>
> >>Demo = 18446744073709551615.000
> >>Demo - 1 = 18446744073709551613.000
> >
> >Ok, that's a bug.
>
> Is it? We are printing a long double, which IIRC has 19 significant
> digits. The ``error'' here happens in the 20th digit, unless I'm
> mistaken.
>
Below is what C99 has to say. Since DJGPP/GCC supports 64-bit precision, my
assumption is that we should produce 21 digits. As the footnote says,
If the minimum-width IEC 60559 extended format (64 bits
of precision) is supported, DECIMAL_DIG shall be at least 21.
F.4 Floating to integer conversion
[#1] If the floating value is infinite or NaN or if the
integral part of the floating value exceeds the range of the
integer type, then the invalid exception is raised and the
resulting value is unspecified. Whether conversion of non-
integer floating values whose integral part is within the
range of the integer type raises the inexact exception is
unspecified.288)
F.5 Binary-decimal conversion
[#1] Conversion from the widest supported IEC 60559 format
to decimal with DECIMAL_DIG digits and back is the identity
function.289)
[#2] Conversions involving IEC 60559 formats follow all
pertinent recommended practice. In particular, conversion
between any supported IEC 60559 format and decimal with
DECIMAL_DIG or fewer significant digits is correctly
rounded. |
____________________
288ANSI/IEEE 854, but not IEC 60559 (ANSI/IEEE 754),
directly specifies that floating-to-integer conversions
raise the inexact exception for non-integer in-range
values. In those cases where it matters, library
functions can be used to effect such conversions with or
without raising the inexact exception. See rint, lrint,
llrint, and nearbyint in <math.h>.
289If the minimum-width IEC 60559 extended format (64 bits
of precision) is supported, DECIMAL_DIG shall be at least
21. If IEC 60559 double (53 bits of precision) is the
widest IEC 60559 format supported, then DECIMAL_DIG shall
be at least 17. (By contrast, LDBL_DIG and DBL_DIG are
19 and 15, respectively, for these formats.)
--part1_16e.2264c067.2c67fe7c_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable
<HTML><FONT FACE=3Darial,helvetica><FONT SIZE=3D3 FAMILY=3D"SERIF" FACE=3D"=
Georgia" LANG=3D"0">In a message dated 8/10/2003 3:30:30 PM Eastern Standard=
Time, eliz AT elta DOT co DOT il writes:<BR>
<BR>
<BLOCKQUOTE TYPE=3DCITE style=3D"BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT=
: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px"></FONT><FONT COLOR=3D"#000000"=
style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D2 FAMILY=3D"SANSSERIF" FACE=3D"A=
rial" LANG=3D"0">>Date: Sun, 10 Aug 2003 14:17:13 -0400<BR>
>From: DJ Delorie <dj AT delorie DOT com><BR>
><BR>
>>Behold:<BR>
>><BR>
>>Demo =3D 18446744073709551615.000<BR>
>>Demo - 1 =3D 18446744073709551613.000<BR>
><BR>
>Ok, that's a bug.<BR>
<BR>
Is it? We are printing a long double, which IIRC has 19 significant<BR=
>
digits. The ``error'' here happens in the 20th digit, unless I'm<BR>
mistaken.<BR>
</BLOCKQUOTE><BR>
</FONT><FONT COLOR=3D"#000000" style=3D"BACKGROUND-COLOR: #ffffff" SIZE=3D3=
FAMILY=3D"SERIF" FACE=3D"Georgia" LANG=3D"0"><BR>
Below is what C99 has to say. Since DJGPP/GCC supports 64-bit precisio=
n, my assumption is that we should produce 21 digits. As the footnote=20=
says,<BR>
<BR>
If the minimum-width IEC 60559 extended=
format (64 bits<BR>
of precision) is supported, DECIMAL_DIG=
shall be at least 21. <BR>
<BR>
<BR>
F.4 Floating to integer conversio=
n<BR>
<BR>
[#1] If the floating value is infinite&=
nbsp; or NaN or if the<BR>
integral part of the floating value exc=
eeds the range of the<BR>
integer type, then the invalid exceptio=
n is raised and the<BR>
resulting value is unspecified.&n=
bsp; Whether conversion of non-<BR>
integer floating values whose integral=20=
part is within the<BR>
range of the integer=20=
type raises the inexact exception is<BR>
unspecified.288)<BR>
<BR>
F.5 Binary-decimal conversion<BR>
<BR>
[#1] Conversion from the widest support=
ed IEC 60559 format<BR>
to decimal with DECIMAL_DIG digit=
s and back is the identity<BR>
function.289)<BR>
<BR>
[#2] Conversions involving&=
nbsp; IEC 60559 formats follow all<BR>
pertinent recommended practice. I=
n particular, conversion<BR>
between any supported =
IEC 60559 format and decimal with<BR>
DECIMAL_DIG or fewer =20=
significant digits is correctly<BR>
rounded. &=
nbsp;  =
; &nb=
sp; &=
nbsp; |<BR>
<BR>
____________________<BR>
<BR>
288ANSI/IEEE 854, but =
not IEC 60559 (ANSI/IEEE 754),<BR>
directly specif=
ies that floating-to-integer conversions<BR>
raise the inexa=
ct exception for non-integer in-range<BR>
values. &n=
bsp; In those cases where it matters, li=
brary<BR>
functions can be used=
to effect such conversions with or<BR>
without raising=
the inexact exception. See rint, lrint,<BR>
llrint, and nearbyint=
in <math.h>.<BR>
<BR>
289If the minimum-width IEC 60559 exten=
ded format (64 bits<BR>
of precision) is supp=
orted, DECIMAL_DIG shall be at least<BR>
21. If IEC 6055=
9 double (53 bits of precision) is the<BR>
widest IEC 60559 form=
at supported, then DECIMAL_DIG shall<BR>
be at least 17. =
(By contrast, LDBL_DIG and DBL_DIG are<BR>
19 and 15, respective=
ly, for these formats.)<BR>
<BR>
</FONT></HTML>
--part1_16e.2264c067.2c67fe7c_boundary--
- Raw text -