Article View: gnu.gcc.help
Article #42008FP weirdness, i586, 2.7.0, linux
From: Amish Dave
Date: Sat, 27 Jan 1996 00:00
Date: Sat, 27 Jan 1996 00:00
34 lines
1333 bytes
1333 bytes
On a P133 running Linux1.2.13 with gcc-2.7.0, I get strange behavior with
the code below. Sparc2-SunOS-gcc2.6.3 and Alpha-DecUNIX2.3c-gcc2.7.0
behave correctly with the same code.
#include <stdio.h>
main()
{
int a = 20, b = 50, c;
c = (int)(0.7 * (a + b));
printf("c = %d\n", c);
c = (int)(0.7 * 70);
printf("c = %d\n", c);
}
When compiled without any options (gcc -o foo foo.c), on the Pentium, it
prints out
c = 48
c = 49
The correct output should be:
c = 49
c = 49
On Sparc-SunOS-2.6.3 or Alpha-DUnix3.2c-2.7.0 machines, it works correctly.
I can get it to function correctly on the Pentium with -msoft-float, but...
What's going on?
Thanks,
--
Amish S. Dave University of Chicago
amish@data.uchicago.edu Biology Grad. Student
Technical Details
Message-ID:
<DLtLuF.KEC@midway.uchicago.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,7168856f3962c151,start X-Google-Attributes: gid11318c,public From: amish@data.uchicago.edu (Amish Dave) Subject: FP weirdness, i586, 2.7.0, linux Date: 1996/01/27 Message-ID: <DLtLuF.KEC@midway.uchicago.edu> X-Deja-AN: 136696184 distribution: usa sender: news@midway.uchicago.edu (News Administrator) x-nntp-posting-host: data.uchicago.edu organization: University of Chicago newsgroups: gnu.gcc.help