#27064 [Opn->Bgs]: The mod function of % does not return the same results of fmod.
| From: | sniper@php.net | Date: | Tue, 27 Jan 2004 20:54:23 +0000 |
| Subject: | #27064 [Opn->Bgs]: The mod function of % does not return the same results of fmod. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53988@lists.php.net to get a copy of this message | ||
ID: 27064
Updated by: sniper@php.net
Reported By: ngaugler at ngworld dot net
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: FreeBSD 4.9 / Linux 2.4.23
PHP Version: 4.3.4
New Comment:
Yes, you're dealing with floats. Of course fmod() works.
(try doing 'var_dump(2190988683);'...)
Previous Comments:
------------------------------------------------------------------------
[2004-01-27 15:35:06] ngaugler at ngworld dot net
Description:
------------
When performing a % (mod) function on two numbers, PHP returns negative
values when it should not. Example:
PHP:
(2190988683 % 3) returns -1
fmod(2190988683,3) returns 0
Perl:
(2190988683 % 3) returns 0
Reproduce code:
---------------
<?
echo "(2190988683 % 3) = " . (2190988683 % 3). "<br>\n";
echo "fmod(2190988683,3) = " . fmod(2190988683,3) . "<br>\n";
?>
Expected result:
----------------
(2190988683 % 3) = 0
fmod(2190988683,3) = 0
Actual result:
--------------
(2190988683 % 3) = -1
fmod(2190988683,3) = 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27064&edit=1