note 36635 deleted from language.operators.arithmetic by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 15:01:40 +0000 |
| Subject: | note 36635 deleted from language.operators.arithmetic by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189792@lists.php.net to get a copy of this message | ||
Note Submitter: todd at magnifisites dot com
----
There isn't much detail in the PHP Manual regarding the PHP modulus operator (%). It seems as
though the PHP modulus operator (%) works on integer operands. If PHP operates like Perl, then the
modulus operator (%) converts its operands to integers before finding the remainder according to
integer division. Testing seems to prove the theory:
<?php
$dividend = 7;
$divisor = 2.4;
print $dividend%$divisor; // prints 1
print fmod($dividend, $divisor); // prints 2.2
?>