Robin Vickery schreef:
2008/7/15 tedd <[EMAIL PROTECTED]>:
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.

which makes php casting so much fun:

$ php -r 'echo (string)(0.7 - 0.2) == 0.5 ? "true\n" : "false\n";'
true




-robin



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to