note 36586 added to language.operators.arithmetic
| From: | tristan at pc-seller dot com | Date: | Wed, 15 Oct 2003 15:50:29 +0000 |
| Subject: | note 36586 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-58637@lists.php.net to get a copy of this message | ||
to do a integer divide
$a = 5;
$b = 3;
$a / $b = 1.66666;
wheras we want:
$a / $b = 1;
and
$a % $b = 2; (Modulus)
the answer I find is to do:
$integer_divide = floor($a/$b);
which bascially removes anything after the decimal point.
AFAIK, there is no proper function for this, odd considering there is a modulus function.
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36586
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36586&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36586&report=yes
Search -- http://master.php.net/manage/user-notes.php