Re: Subtracting Large Numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I would guess integer overflow.

On 2/17/06, Bruce <bvanderw@xxxxxxxxx> wrote:
>
> 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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux