This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51656] New: C front end and strtold handle hexadecimal floating differently
- From: "exponent-bias at yandex dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 22 Dec 2011 20:43:17 +0000
- Subject: [Bug c/51656] New: C front end and strtold handle hexadecimal floating differently
- Auto-submitted: auto-generated
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