Re: Math Weirdness
| From: | Robin Vickery | Date: | Tue, 15 Jul 2008 13:52:26 +0000 |
| Subject: | Re: Math Weirdness | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-276830@lists.php.net to get a copy of this message | ||
2008/7/15 tedd <tedd.sperling@gmail.com>:
>
> I said:
>
> "Round-off errors normally don't enter into things unless your doing
> multiplication and division operations."
>
> And that is not "Bull" -- it's true. You can add and subtract all the
> floating point numbers (the one's we are talking about here) you want
> without any rounding errors whatsoever.
$ php -r 'echo 0.7 - 0.2 == 0.5 ? "true\n" : "false\n";'
false
The operation you do isn't important. You just can't represent certain
numbers exactly in binary, just as you can't represent 1/3 exactly in
decimal. They have to be rounded internally.
-robin