note 89930 added to language.types.float

From: Date: Sun, 29 Mar 2009 16:53:23 +0000
Subject: note 89930 added to language.types.float
Groups: php.notes 
Request: Send a blank email to php-notes+get-152584@lists.php.net to get a copy of this message
The example, above is good, but the explanation is misleading: "This is due to the fact that it is impossible to express some fractions in decimal notation with a finite number of digits. For instance, 1/3 in decimal form becomes 0.3 [repeating]." What the author *meant* to write is This is due to the fact that some (most) real numbers cannot be represented with a finite number of binary digits, or indeed, a finite number of digits in any radix. For example, 1/3 is 0.3333333... [no vinculum in comment editor!] represented with two significant decimal digits is truncated to 0.33 which is *not* exactly 1/3. Even this explanation is unsatisfactory, since for any radix other than two (assuming a machine built on binary logic) we need to represent the significand (mantissa for us old-timers!) itself with a finite number of binary digits. So rather than present a good example with a misleading explanation, it would be preferable to present the same good example with a link to a good explanation, e.g. http://en.wikipedia.org/wiki/Floating_point . ---- Server IP: 69.147.83.197 Probable Submitter: 72.208.135.183 ---- Manual Page -- http://www.php.net/manual/en/language.types.float.php Edit -- https://master.php.net/note/edit/89930 Del: integrated -- https://master.php.net/note/delete/89930/integrated Del: useless -- https://master.php.net/note/delete/89930/useless Del: bad code -- https://master.php.net/note/delete/89930/bad+code Del: spam -- https://master.php.net/note/delete/89930/spam Del: non-english -- https://master.php.net/note/delete/89930/non-english Del: in docs -- https://master.php.net/note/delete/89930/in+docs Del: other reasons-- https://master.php.net/note/delete/89930 Reject -- https://master.php.net/note/reject/89930 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152584) next »