public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "exponent-bias at yandex dot ru" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/51656] New: C front end and strtold handle hexadecimal floating differently Date: Thu, 22 Dec 2011 20:45:00 -0000 [thread overview] Message-ID: <bug-51656-4@http.gcc.gnu.org/bugzilla/> (raw) 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
next reply other threads:[~2011-12-22 20:43 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-12-22 20:45 exponent-bias at yandex dot ru [this message] 2011-12-23 9:16 ` [Bug c/51656] " rguenth at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-51656-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).