You are here: Re: Subtracting Large Numbers « PHP Programming Language « IT news, forums, messages
Re: Subtracting Large Numbers

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация