Monthly Archives: May 2013


Precision of calculation with floating point numbers

I found some curiosity issues during finding optimal tool for compilation our program. Results of computations be different for different tools and different optimisation flags.
For investigating this issue I write simple code(full sources on github):

In this small test program I can’t reproduce different results for different flags. But 5 different results for so similar programs is enough to demonstrate discovered effect.

Source code and tool Result Computation time, s
Assembler 1.53436944477410652787 3.81
gcc long 1.53436944477462278158 4.4
gcc double 1.53436944477389380914 4.4
icc long 1.53436944477397574360 6.88
icc double 1.53436944477334602510 1.50

p.s. also I found that manually written assembly code 15% faster than code on C in spite of using “-O2” optimisation flag.