Based on our investigation and the gcc documentation , we think there is a Bug in GCC 4.1.2
Firstly, according to the doc and our understanding, the error caused by rounding should be small, for instance, some systems may treat 5.000 as 4.998. However, in our case, the difference is quit big, about 40% by compare -0.7240616609 to -0.5413411329464. I think it can't be ignored. Secondly, -frounding-math and -fno-rounding-math are two gcc options to control rounding. However, using -O0, for both two options, We got the same value, -0.7240616609. But using -O3 (or -O1), We got the same value, -0.5413411329464. This means changing rounding option doesn't affect the result. Thirdly, in the case, function double ahdlDoFloatDiv(double a, double) is to return the result of a/b. If I directly use a/b, instead of function, for -O3, the result is -0.7240616609, the same as -O0. If the issue is caused by rounding, both two ways should have the same result. But now it is different. Finally, we simplified the c code as below and can reproduce the problem: #include <math.h> #include <stdio.h> #include <stdlib.h> double ahdlDoFloatDiv (double a, double b) { return a/b; } // #define ahdlDoFloatDiv(a, b) (a/b) int main() { double pow_tmp = 0; printf("%f\n", ahdlDoFloatDiv((((((((((2.7182818284590451)) + (((ahdlDoFloatDiv((((-(((2.7182818284590451)) * ((((((1.00000000000000000000e+00))) * 1.00000000000000000000e+00))))))), (((( pow_tmp = (2.7182818284590451)) * pow_tmp)))))))))) * (((((2.7182818284590451)) - (((ahdlDoFloatDiv(1.00000000000000000000e+00, (2.7182818284590451))))))))))) - ((((((((2.7182818284590451)) - (((ahdlDoFloatDiv((((-(((2.7182818284590451)) * ((((((1.00000000000000000000e+00))) * 1.00000000000000000000e+00))))))), (((( pow_tmp = (2.7182818284590451)) * pow_tmp)))))))))) * (((((2.7182818284590451)) + (((ahdlDoFloatDiv(1.00000000000000000000e+00, (2.7182818284590451)))))))))))), (((( pow_tmp = ((((2.7182818284590451)) - (((ahdlDoFloatDiv(1.00000000000000000000e+00, (2.7182818284590451)))))))) * pow_tmp)))) ); return 0; } Please use gcc4.1.2 to compile it under Linux and you can reproduce the bug. For -O3, the printed value is -0.541341, for -O0, it is -0.724062. If comment the function ahdlDoFloatDiv and uncomment the macro definition, both -O0 and -O3 have the same result, -0.724062. This issue causes our problem to producing incorrect values, even lead to convergence issue. -- Summary: Rounding off error in GCC 4.1.2 Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: satyaakam at yahoo dot co dot in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33809