note 42424 deleted from language.operators.arithmetic by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 15:01:51 +0000 |
| Subject: | note 42424 deleted from language.operators.arithmetic by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189793@lists.php.net to get a copy of this message | ||
Note Submitter: csaba at alum dot mit dot edu
----
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