note 67247 deleted from language.operators.arithmetic by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 15:04:55 +0000 |
| Subject: | note 67247 deleted from language.operators.arithmetic by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189804@lists.php.net to get a copy of this message | ||
Note Submitter: bxm AT cs d0t nott d0t ac d0t uk
----
An implementation of the classical modulus operator (as in mathematics or Java). An alternative to
the one given below, which was more elegant. This implementation maybe more efficient?
// Computes...
// Mathematics: $a (mod $b)
// Java: $a % $b
function modulus( $a, $b )
{
if( $a < 0 )
{
return $b - ( abs( $a ) % $b );
}
else
{
return $a % $b;
}
}