#42418 [Opn->Bgs]: Strange behaviour of modulus function
| From: | iliaa@php.net | Date: | Sun, 26 Aug 2007 16:49:48 +0000 |
| Subject: | #42418 [Opn->Bgs]: Strange behaviour of modulus function | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116679@lists.php.net to get a copy of this message | ||
ID: 42418
Updated by: iliaa@php.net
Reported By: onyjgyjz at trashmail dot net
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: WinXP
PHP Version: 5.2.3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
11213214321 overflows an integer and is converted into a negative
number. The modulus operation is then performed on a negative value,
hence the -1 return value.
Previous Comments:
------------------------------------------------------------------------
[2007-08-24 19:45:39] onyjgyjz at trashmail dot net
Description:
------------
Somehow the modulus operator does not behave as expected on some
special numbers.(maybe integer overflow or something like that?)
Php-version i used:
PHP 5.2.3 (cli) (built: May 31 2007 09:37:22)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Reproduce code:
---------------
$a=11213214321;
echo $a % 2;
Expected result:
----------------
Output of: 1
Actual result:
--------------
Output of: -1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42418&edit=1