Guess the answer
(0.1 + 0.1) * 10;
mkotsur@n-racoon:~$ python -i
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more
>>> (0.1 + 0.1) * 10;
Python, PHP, Java… => Same problems...
“The IEEE Standard for Floating-Point Arithmetic
set the standard for floating-point computation for 23 years. It
became the most widely-used standard for floating-point
computation, and is followed by many CPU and FPU
implementations. Its binary floating-point formats and
arithmetic are preserved in the new IEEE 754-2008 standard
which replaced it.”
Sign: 0 for “+”. 1 for “-”.
0 in our case
Exponent bias: + 127 (01111111) – half of a byte.
01111100 in our case
Mantissa (fraction): integer part always 1, 23 bits of fraction
00000000000000000000000 (23 zeros) in our case
What about other numbers?
0.125 = 0 01111100 00000000000000000000000
Sign Exponent Mantissa