ID:               27064
 User updated by:  ngaugler at ngworld dot net
 Reported By:      ngaugler at ngworld dot net
 Status:           Bogus
 Bug Type:         Math related
 Operating System: FreeBSD 4.9 / Linux 2.4.23
 PHP Version:      4.3.4
 New Comment:

Ok, so where in the documentation does it explain that you can't use %
on floats?  I love how PHP just doesn't work as expected, yet Perl,
MySQL, you name it, all have no problems.


Previous Comments:
------------------------------------------------------------------------

[2004-01-27 15:54:22] [EMAIL PROTECTED]

Yes, you're dealing with floats. Of course fmod() works.
(try doing 'var_dump(2190988683);'...)



------------------------------------------------------------------------

[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

Reply via email to