|
Posted by Michael Austin on 02/18/06 01:43
Bruce 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
http://us2.php.net/intval
"The maximum value depends on the system. 32 bit systems have a maximum signed
integer range of -2147483648 to 2147483647. So for example on such a system,
intval('1000000000000') will return 2147483647. The maximum signed integer value
for 64 bit systems is 9223372036854775807."
Depends on system, OS, math libraries, cpu type etc...
--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Navigation:
[Reply to this message]
|