Date: Thu, 03 Nov 1994 16:10:29 +0100 From: Peter Csizmadia To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: 2.4/3-2.4/3!=0 main() { register double a1=2.4, b1=3.0; volatile double a2=2.4, b2=3.0; printf("2.4/3-2.4/3 = %le\n", a1/b1-a2/b2); } gcc a.c -lm -O1 go32 a.out 2.4/3-2.4/3 = -3.70255041903800e-17 Is it a normal effect of -O1? (a1=a2, b1=b2, a1/b1!=a2/b2) Other problem: #include #include main() { volatile double a = 1.54734129e8; double b = sqrt(1+a*a); double x = a/b; printf("1-x=%le\n", 1.0-x); printf("1-x=%le\n", 1.0-x); printf("x%s1\n", (x==1.0)? "==":"!="); printf("1-x=%le\n", 1.0-x); } I compiled it with DJGPP 1.12.maint2: gcc f.c -o f -lm -O1 gcc f.C -o fpp -lm -O1 These are the results on a 386 with a coprocessor: go32 f 1-x=2.08708918203460e-17 1-x=2.08708918203460e-17 x==1 (?) 1-x=0.00000000000000e+00 go32 fpp 1-x=-2.09251019289702e-17 (it should be >=0) 1-x=-2.09251019289702e-17 x==1 (?) 1-x=0.00000000000000e+00 The numbers are a bit different with emu387, but the problem is the same. I think one (at least) of the optimizations turned on by -O1 is buggy, but don't know which. And I have no idea about the cause of the difference between C and C++ compiling.