note 23967 deleted from language.operators.arithmetic by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:07:59 +0000 |
| Subject: | note 23967 deleted from language.operators.arithmetic by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58381@lists.php.net to get a copy of this message | ||
Note Submitter: niekomaatjes@hotmail.com
----
Someone wrote:
(int)($foo / $bar) will not always work because the number "5" in float could actually be
represented as 4.9999... etc. which (int) will
convert to 4.
To avoid this, you can add a real tiny fraction to the total, like this:
(int)($foo / $bar + 0.0000001)