Strange arithmetics
No. 205
Q: |
From ordinary arithmetics we expect a + b - c = a - c + b. But executing the subsequent code yields:
Explain these two different results. |
||||||
A: |
Short answer: The two values 1000000000 or
and 0.000000001 or
differ by 18 orders of magnitude. An eight
byte Longer answer: For summing up the int literal
Thus in 8 byte IEEE 754 representation both
|