note 95199 deleted from function.fmod by danbrown
| From: | danbrown@php.net | Date: | Fri, 18 Dec 2009 03:59:23 +0000 |
| Subject: | note 95199 deleted from function.fmod by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164100@lists.php.net to get a copy of this message | ||
Note Submitter: Michael Fallows
----
@ linkboss at gmail dot com
They are not the same if you are working with floats. The % operator converts the numbers into
integers.
One example taken from the comments page on Arithmetic Operators:
(todd at magnifisites dot com)
<?php
$dividend = 7;
$divisor = 2.4;
print $dividend%$divisor; // prints 1
print fmod($dividend, $divisor); // prints 2.2
?>
Several other people have also commented on this "functionality" on the same page (
http://www.php.net/manual/en/language.operators.arithmetic.php).