0.30000000000000004
0.30000000000000004 is the result in the most common example used on the internet to demonstrate small deviations between human common decimal fractions math and computer common binary floating-point arithmetic.
Problem and example
The example is that 0.2 + 0.1 results in 0.30000000000000004 in binary floating-point with the most common datatype IEEE 754[1] 'double' (binary64).
These deviations occur because the binary datatypes cannot exactly represent most decimal fractions but use approximated binary deputies.
Thus, the calculation becomes 0.2000000000000000111022... + 0.1000000000000000055511... , the binary exact result 0.3000000000000000166533... isn't representable in the datatype, would require 54 bits of significand where only 53 are available, and thus becomes rounded to a representable value, 0.3000000000000000444089... for which the 'SRT' ( Shortest Round Trip ) decimal correspondent is 0.30000000000000004 .
For verification one can use the IEEE 754 Calculator from Prof. Weitz, HAW Hamburg, it can be found at weitz.de/ieee.
Reproduction of problem
In e.g. spreadsheets it needs some effort to demonstrate these deviations, as they cover up by e.g. only displaying 15 significant digits.
A funny, while not exact in every detail, video about it can be found on YouTube 'Why do computers suck at math?'.
The problem / example has its own website: 'Floating Point Math' ( 0.30000000000000004.com ).
More info about this type of deviation and background can be found at Goldberg: 'What Every Computer Scientist Should Know About Floating-Point Arithmetic' [1], or on a less scientific level at: 'What Every Programmer Should Know About Floating-Point Arithmetic' [2].
The problem
It is not the only example, but one of myriads of similar deviations; it's not only additions but all types of calculations affected, and not all problem cases involve rounding, e.g. 4.4 + 2.2 -> 6.6000000000000005 fails without it.
The deviations are often considered negligible as being very, very, very small, which is right, but they may stack up, multiply up, or even 'exponentially explode' and then harm the usability of computer-calculated results.
References
- ↑ 754-2019 - IEEE Standard for Floating-Point Arithmetic ( caution: paywall ). 2019. doi:10.1109/IEEESTD.2019.8766229. ISBN 978-1-5044-5924-2. Retrieved 2024-10-29. Search this book on
This article "0.30000000000000004" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:0.30000000000000004. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.
