#39610 [Bgs]: Number of return Modular_arithmetic is negative..
| From: | ocracy at msn dot com | Date: | Fri, 24 Nov 2006 13:05:32 +0000 |
| Subject: | #39610 [Bgs]: Number of return Modular_arithmetic is negative.. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105407@lists.php.net to get a copy of this message | ||
ID: 39610
User updated by: ocracy at msn dot com
Reported By: ocracy at msn dot com
Status: Bogus
Bug Type: *General Issues
Operating System: windows
PHP Version: 4.4.4
New Comment:
i beg your pardon.. i acted inattentive, i didnt pay attention to
PHP_INT_MAX and nubmer of float
Previous Comments:
------------------------------------------------------------------------
[2006-11-23 23:11:17] tony2001@php.net
# php -r 'var_dump(pow(2,31));' is greater than PHP_INT_MAX, so it
cannot be represented as positive integer when casted to int.
Hence "Note: Remainder $a % $b is negative for negative $a."
http://www.php.net/manual/en/language.operators.arithmetic.php
------------------------------------------------------------------------
[2006-11-23 22:59:01] ocracy at msn dot com
Description:
------------
Number of return Modular_arithmetic must be positive in general but i
tryed high nubmer like(2^30++) in Modular_arithmetic, PHP gave me
negative nubmer...
example: x=2^31, y=x%20, y = negative in PHP
Reproduce code:
---------------
<?php
$number = 31;
$pow = pow(2,$number);
$random = rand(10,50);
echo ($pow%$random);
?>
Expected result:
----------------
Negative numbers..
Like
-6
-38
-44
..
..
Actual result:
--------------
nubmer of return will be positive..
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39610&edit=1