note 42424 added to language.operators.arithmetic
| From: | csaba at alum dot mit dot edu | Date: | Sun, 16 May 2004 09:32:49 +0000 |
| Subject: | note 42424 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69665@lists.php.net to get a copy of this message | ||
The function below is not a replacement for http://php.net/fmod
Rather, it is the classic (mathematician's) modulo where the resultant value is always
non-negative, in the range [0,$base). For example, mod(-9,7) => 5. When both arguments are
integers, you get the classic notion of the % operator.
function mod($num, $base) {
return ($num - $base*floor($num/$base)); }
Csaba Gabor
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42424
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42424&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42424&report=yes
Search -- http://master.php.net/manage/user-notes.php