Bug #12155 Updated: modulus %
| From: | phil dot cavazos at salemhospital dot org | Date: | Sat, 01 Jun 2002 20:47:25 +0000 |
| Subject: | Bug #12155 Updated: modulus % | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-9119@lists.php.net to get a copy of this message | ||
ID: 12155
Updated by: phil.cavazos@salemhospital.org
Reported By: yaragn@hotmail.com
Status: Bogus
Bug Type: Math related
Operating System: linux 2.4.3
PHP Version: 4.0.5
New Comment:
The modulus operator seems to also fail with negative integers.
The operation -1%7 should return 6 but instead returns -1
on negative numbers it simply returns the divisor
Previous Comments:
------------------------------------------------------------------------
[2001-08-07 12:47:33] jmcastagnetto@php.net
See Bug #12623 for a more complete explanation on modulus
( http://www.php.net/bugs.php?id=12623 )
------------------------------------------------------------------------
[2001-08-06 19:57:53] jeroen@php.net
float % int could lead to rounding difficulties, which is not a bug.
------------------------------------------------------------------------
[2001-07-13 20:34:11] yaragn@hotmail.com
Integer limited to 2047000000 so there.
------------------------------------------------------------------------
[2001-07-13 18:29:23] yaragn@hotmail.com
Appears to be broken on large(r) integers. Is this a limitation on the
type used? (I am coding working ip2long/long2ip).
$temp = 3194548456;
print "correct: " . ($temp - 255*floor($temp/255));
print "php: " . $temp % 255 . "<br>";
as defined in maths, the % is equiv to MOD(n, d) = n - d*INT(n/d)
where n is the number, d is the divisor.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=12155&edit=1