note 99502 added to language.operators.arithmetic
| From: | cadde at notmymail dot com | Date: | Fri, 20 Aug 2010 11:42:31 +0000 |
| Subject: | note 99502 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171879@lists.php.net to get a copy of this message | ||
Note on the modulus operators returning negative values for great numbers... For instance:
<?PHP
$a = pow(2, 31); // You expect it to be 2147483648 but under the surface it's actually
-2147483648 because the variable is signed.
$a = 50856937683; // You expect it to be 50856937683 but something odd is going on here where you
are breaking the 32 bit storage and it converts to either -682669869 or -1116408691
?>
I don't have the time to actually check which of the two negatives it converts to but that is
why it returns a negative value either way.
----
Server IP: 69.147.83.197
Probable Submitter: 83.249.116.147
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- https://master.php.net/note/edit/99502
Del: integrated -- https://master.php.net/note/delete/99502/integrated
Del: useless -- https://master.php.net/note/delete/99502/useless
Del: bad code -- https://master.php.net/note/delete/99502/bad+code
Del: spam -- https://master.php.net/note/delete/99502/spam
Del: non-english -- https://master.php.net/note/delete/99502/non-english
Del: in docs -- https://master.php.net/note/delete/99502/in+docs
Del: other reasons-- https://master.php.net/note/delete/99502
Reject -- https://master.php.net/note/reject/99502
Search -- https://master.php.net/manage/user-notes.php