public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Marco Bernardo <bernardo@sti.uniurb.it> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c/8395: gcc 2.95.4 and 3.2 generate wrong code for double on intel Date: Thu, 31 Oct 2002 00:46:00 -0000 [thread overview] Message-ID: <20021031084601.28319.qmail@sources.redhat.com> (raw) The following reply was made to PR c/8395; it has been noted by GNATS. From: Marco Bernardo <bernardo@sti.uniurb.it> To: Bruce Allen <ballen@aei.mpg.de> Cc: gcc-gnats@gcc.gnu.org, <gcc-prs@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <nobody@gcc.gnu.org> Subject: Re: c/8395: gcc 2.95.4 and 3.2 generate wrong code for double on intel Date: Thu, 31 Oct 2002 09:39:56 +0100 (CET) Dear Bruce, Thanks for your message. >There's nothing wrong here. It's very reasonable for this code to >produce ~10^-16 for double. >The reason is tha the number 1.2 can not be exactly represented as an >IEEE754 floating point number. >The numbers 5 and -6 CAN be exactly represented. I can understand that the problem is related to the IEEE 754 representation. However, let me point out some weaknesses in your argument: 1. If -1.2 does not have an exact representation, why is the value of variable y (i.e. -1.2) correctly displayed through printf? 2. Let us consider the following variant of the program I attached to my report: #include <stdio.h> int main(void) { double x, y, z, y_times_z; x = -6.0; y = -1.2; z = 5; y_times_z = y * z; printf("%g %g %g %g %g %g\n", x, y, z, x - y * z, y_times_z, x - y_times_z); return(0); } With respect to the previous version, I added variable y_times_z together with the visualization of y_times_z as well as x - y_times_z. Surprisingly enough, the output is -6 -1.2 5 -2.22045e-16 -6 0 i.e. the correct values are somehow restored. Now, passing through an additional variable like y_times_z is how the target code produced by gcc should be organized, isn't it? If so, then both x - y * z and x - y_times_z should evaluate to 0. Since this is not the case, gcc contains a bug in the way it translates the arithmetical expressions when doubles are involved. In conclusion, I still believe that gcc contains a serious bug on the intel platform, which should hopefully be fixed asap. If the bug is fixed, or you or someone else reading this message is able to point out some flaw in my argument, then my colleagues, my students, and I will be glad to keep using gcc. Best regards, Marco @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Prof. Marco Bernardo Universita` di Urbino Centro per l'Applicazione delle Scienze e Tecnologie dell'Informazione Piazza della Repubblica 13, 61029 Urbino, Italy Phone: +39-0722-4475 - E-mail: bernardo@sti.uniurb.it Fax: +39-0722-4475 - WWW: http://www.sti.uniurb.it/bernardo/ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
next reply other threads:[~2002-10-31 8:46 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-10-31 0:46 Marco Bernardo [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-11-04 9:06 Joseph S. Myers 2002-11-04 9:06 Marco Bernardo 2002-11-04 3:06 Bruce Allen 2002-11-02 22:26 Bruce Allen 2002-11-02 22:26 Bruce Allen 2002-11-02 8:26 Tim Prince 2002-11-02 7:56 Toon Moene 2002-11-02 7:46 Marco Bernardo 2002-10-31 0:56 Bruce Allen 2002-10-30 12:57 bangerth 2002-10-30 9:36 Bruce Allen 2002-10-30 0:26 bernardo
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=20021031084601.28319.qmail@sources.redhat.com \ --to=bernardo@sti.uniurb.it \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@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).