Jump to content

Draft:0.30000000000000004

From Wikipedia, the free encyclopedia

( questions to reviewers, to be removed before publish:

I didn't intent to re-invent the wheel or re-write other sources, this article is intended as sort of hint, and at 0.30000000000000004.com people interested can get further info.

I don't know about any more reliable source than the original IEEE paper for the standard, acc. your request I added the weitz IEEE calculator and 'Goldberg' as sources, can't say if they will make it in the references list.

Hope to be qualified now :-) )

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.

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 evolve because the binary datatypes can't exactly represent most of 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 bit of significand where only 53 are available, and thus becomes rounded to a representable value, 0.3000000000000000444089... for which the 'SRT' ( Shortest Round Tripping ) decimal correspondent is 0.30000000000000004 .

For verification one can use the IEEE 754 Calculator from Prof. Weitz, HAW Hamburg, it can be found at [1]

In e.g. spreadsheets it needs some efforts to demonstrate these deviations, they cover up by e.g. only displaying 15 significant digits.

More Info about this type of deviation and background can be found at Goldberg: 'What Every Computer Scientist Should Know About Floating-Point Arithmetic': [2] or on a less scientific level at: 'What Every Programmer Should Know About Floating-Point Arithmetic' [3]

The problem / example has got it's own website: 'Floating Point Math', 0.30000000000000004.com[4] .

A funny while not exact in every detail video about it can be found on youtube: 'Why do computers suck at math?' [5]

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.

The deviations are often considered neglectable as being very very very small, that's right but they may stack up, multiply up, or even 'exponentionally explode' and then harm usability of computer calculated results.

References

[edit]
  1. ^ 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.