note 26439 deleted from language.operators.arithmetic by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:08:16 +0000 |
| Subject: | note 26439 deleted from language.operators.arithmetic by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58384@lists.php.net to get a copy of this message | ||
Note Submitter: tipsen at imada.sdu.dk
----
The above mentioned method of calculating div using floor() is subject to the same shortcomings as
the method stated earlier:
(int) ($foo / $bar)
As stated in an earlier message (10-Jul-2002 06:41) this will not always work as expected due to
round-off errors - if the above mentioned method fails so will the method using floor() !
The only correct solution to this problem is the answer from 17-Jul-2002 04:14:
function div($a,$b){
return ($a-($a % $b))/$b;
}