note 30846 added to language.types.float

From: Date: Tue, 01 Apr 2003 08:20:41 +0000
Subject: note 30846 added to language.types.float
Groups: php.notes 
Request: Send a blank email to php-notes+get-46052@lists.php.net to get a copy of this message
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. -- http://www.php.net/manual/en/language.types.float.php http://master.php.net/manage/user-notes.php?action=edit+30846 http://master.php.net/manage/user-notes.php?action=delete+30846 http://master.php.net/manage/user-notes.php?action=reject+30846

« previous php.notes (#46052) next »