floating point bug -- or misunderstanding?
Derrick Bass
derrick@tapir.Caltech.EDU
Fri Aug 14 09:07:00 GMT 1998
I may have found a bug in egcs, but more likely I just don't
understand floating point math.
Can someone tell me enough about floating point (or point me to an
explanation) to explain the output of the following program?
#include <stdio.h>
main() {
float a,b,c,d;
a = 1;
b = 3;
c = a/b;
d = c * b;
printf("%g\n", a - c * b);
printf("%g\n", a - d);
}
I compiled the program with egcs-19980803 on a pentium pro linux
machine with no optimization and the output was
-2.98023e-08
0
Shouldn't these numbers be equal?
Derrick Bass
More information about the Gcc-bugs
mailing list