note 99502 deleted from language.operators.arithmetic by hholzgra
| From: | hholzgra@php.net | Date: | Thu, 02 Aug 2012 15:07:59 +0000 |
| Subject: | note 99502 deleted from language.operators.arithmetic by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189824@lists.php.net to get a copy of this message | ||
Note Submitter: cadde at notmymail dot com
----
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.