note 34866 deleted from language.operators.arithmetic by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:09:00 +0000 |
| Subject: | note 34866 deleted from language.operators.arithmetic by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58394@lists.php.net to get a copy of this message | ||
Note Submitter: number_co@yahoo.com
----
saforres@alumni.SPAMGUARD.uwaterloo.ca told us that:
"This sort of strategy will not work. Suppose $foo=9999999 and $bar=10000000. Then since
$foo<$bar, you would want int($foo/$bar) to return 0, but 9999999/10000000+0.0000001=1.000000000,
so (int)($foo / $bar + 0.0000001)=1."
I have an idea that will get integer division to work. If you just do it like this:
(int)(($foo+0.01)/$bar)
(providing of course $foo is an integer as well), it'll work.