note 30846 deleted from language.types.float by danbrown
| From: | danbrown@php.net | Date: | Sat, 02 Feb 2013 15:12:17 +0000 |
| Subject: | note 30846 deleted from language.types.float by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193502@lists.php.net to get a copy of this message | ||
Note Submitter:
----
In response to "...the author probably knows what they are talking about..." above:
Of course the author knows what they're talking about. The previous poster missunderstood the
semantics of the author's example of the decimal representation of 1/3. The author is not
suggesting that some property of decimal numbers causes the behaviour, but that the property of
finite binary representations of real numbers which does cause the problem is shared by finite
decimal representations. To paraphrase, the author is saying "10*(0.1+0.7) gives 7.99999...
because of the binary equivalent of the fact that 1/3+2/3 gives 0.99999... when using finite decimal
representations (where 1/3 == 0.33333... and 2/3 == 0.66666..., so 1/3+2/3 ==
(0.33333...)+(0.66666...) == 0.99999... instead of 1)."
The problem occurs with finite representations of real numbers, regardless of base of the number
system used.