note 89930 deleted from language.types.float by danbrown

From: Date: Sun, 29 Mar 2009 16:54:18 +0000
Subject: note 89930 deleted from language.types.float by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152585@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- 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 .

« previous php.notes (#152585) next »