public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/51656] New: C front end and strtold handle hexadecimal floating differently
@ 2011-12-22 20:45 exponent-bias at yandex dot ru
2011-12-23 9:16 ` [Bug c/51656] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: exponent-bias at yandex dot ru @ 2011-12-22 20:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51656
Bug #: 51656
Summary: C front end and strtold handle hexadecimal floating
differently
Classification: Unclassified
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: exponent-bias@yandex.ru
Consider this program:
----
#include <stdlib.h>
#include <stdio.h>
long double f;
int main(void)
{
f = 0x9.1a1c9420419a1a08p0L;
printf("%.15La\n", f);
f = strtold("0x9.1a1c9420419a1a08p0", NULL);
printf("%.15La\n", f);
return EXIT_SUCCESS;
}
----
That program prints:
0x9.1a1c9420419a1a0p+0
0x9.1a1c9420419a1a1p+0
Note the difference in the last mantissas' digits. I believe that difference
can be considered a bug by at least two reasons: 1) the "strtold()" function
seems to be rounding hexadecimals by rules that don't match neither of the
standard rounding mode (including the to-nearest mode for which it should
return 0x9.1a1c9420419a1a0p+0) and 2) that difference breaks user's
expectations in that these two ways of acquiring floating-point values should
behave identically under the same rounding mode.
Command-line options used:
gcc --float-store -g -O0 -o test test.c
Compiler version:
gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Host and target platforms:
32-bit x86 system
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-23 9:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-22 20:45 [Bug c/51656] New: C front end and strtold handle hexadecimal floating differently exponent-bias at yandex dot ru
2011-12-23 9:16 ` [Bug c/51656] " rguenth at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).