From: Operating system: any PHP version: Irrelevant Package: *Math Functions Bug Type: Bug Bug description:Modulo does not calc right (C99 not mathematical correct)
Description: ------------ I found a bug-report that already noted it, but since this is VERY old, i think it should be re-opened or re-mentioned: http://bugs.php.net/bug.php?id=20365 Modulo operator DOES NOT calc right. (-4) mod 10 should be 6, thats the mathematical definition. modulo is NOT the distance to zero. modulo is NOT the remainder while division. the problem is, that the underlying code is written in c/c++, but c99 does NOT have a real modulus, its a remainder-function. here is a site which describes it: http://www.alecjacobson.com/weblog/?p=1140 Test script: --------------- <?php // euclidean result: 6; php result: -4 .... due to the bug in c++ echo (-4)%10; ?> Expected result: ---------------- 6 Actual result: -------------- -1 -- Edit bug report at http://bugs.php.net/bug.php?id=53208&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53208&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53208&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53208&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53208&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53208&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53208&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53208&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53208&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53208&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53208&r=support Expected behavior: http://bugs.php.net/fix.php?id=53208&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53208&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53208&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53208&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53208&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53208&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53208&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53208&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53208&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53208&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53208&r=mysqlcfg