Subtracting Large Numbers
| From: | Bruce | Date: | Fri, 17 Feb 2006 22:09:24 +0000 |
| Subject: | Subtracting Large Numbers | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-230688@lists.php.net to get a copy of this message | ||
I am puzzled by the following code:
<?php
print "<p>MaxInt=".PHP_INT_MAX;
$AA = -190668411;
$BB = -2181087916;
print "<br>AA=$AA";
print "<br>BB=$BB";
$AA = (int)$AA + (int)$BB;
print "<br>AA+BB=$AA";
?>
On some systems, I get:
MaxInt=2147483647
AA=-190668411
BB=-2181087916
AA+BB=-2338152059
On others, I get:
MaxInt=2147483647
AA=-190668411
BB=-2181087916
AA+BB=1923210969
Why the difference?
Thanks...Bruce