note 67188 added to language.operators.arithmetic
| From: | andr3a at 3site dot it | Date: | Mon, 05 Jun 2006 12:14:14 +0000 |
| Subject: | note 67188 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-113238@lists.php.net to get a copy of this message | ||
[ops ... wrong example :D]
just a note about module, it works only with integers.
<?php
$a = pow(2, 31);
$b = ($a / 2) - 1;
echo implode('<br />', array(
$a + $b, // OK => 3221225472
$a - $b, // OK => 1073741825
$a * $b, // OK => 2.3058430070662E+018
$a / $b, // OK => 2.0000000018626
$a % $b // WTF ? => -2
));
?>
maybe bc_mod with a string cast should be a solution
bc_mod((string)pow(2,31), (pow(2,31)/2)-1)
----
Server IP: 213.92.11.19
Probable Submitter: 80.116.51.243
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- http://master.php.net/note/edit/67188
Del: integrated -- http://master.php.net/note/delete/67188/integrated
Del: useless -- http://master.php.net/note/delete/67188/useless
Del: bad code -- http://master.php.net/note/delete/67188/bad+code
Del: spam -- http://master.php.net/note/delete/67188/spam
Del: non-english -- http://master.php.net/note/delete/67188/non-english
Del: in docs -- http://master.php.net/note/delete/67188/in+docs
Del: other reasons-- http://master.php.net/note/delete/67188
Reject -- http://master.php.net/note/reject/67188
Search -- http://master.php.net/manage/user-notes.php