J
Jon Rea
Hi,
I have just tried compiling some scientific calculation code on Redhad
Linux using gcc-3.4.4 that I normally compile on MS Visual C++ 03 and
05. I was surprised to get different floating point answers on the two
systems (identical hardware spec AMD Athlon). Both are being compiled in
'Debug' mode with things like Fast_Math disabled.
After a little debuging and lots of printf() statements, all my errors
are found to be cumulative floating point rounding errors.
Most data is read in as floats and then casted to doubles for internal
matrix calculations, before being casted back to floats for storage and
output.
Questions:
1) What is the best way to deal with floating point behavior differences
on different systems?
2) In a printf("%N.Nf\n",myVal); style statement, what is the highest
number of decimal places that one can be accurate to? %8.3f / %9.4f /
%10.5f ???
3) There is a PRAGMA on VC to allow function level setting of
FloatingPoint compile mode so that you can set Fast/Precise for
individual functions. Is there a cross-platform way to do this?
Many thanks for any help,
There is quite a lot of hair loss over here ;-)
Jon Rea
I have just tried compiling some scientific calculation code on Redhad
Linux using gcc-3.4.4 that I normally compile on MS Visual C++ 03 and
05. I was surprised to get different floating point answers on the two
systems (identical hardware spec AMD Athlon). Both are being compiled in
'Debug' mode with things like Fast_Math disabled.
After a little debuging and lots of printf() statements, all my errors
are found to be cumulative floating point rounding errors.
Most data is read in as floats and then casted to doubles for internal
matrix calculations, before being casted back to floats for storage and
output.
Questions:
1) What is the best way to deal with floating point behavior differences
on different systems?
2) In a printf("%N.Nf\n",myVal); style statement, what is the highest
number of decimal places that one can be accurate to? %8.3f / %9.4f /
%10.5f ???
3) There is a PRAGMA on VC to allow function level setting of
FloatingPoint compile mode so that you can set Fast/Precise for
individual functions. Is there a cross-platform way to do this?
Many thanks for any help,
There is quite a lot of hair loss over here ;-)
Jon Rea