Re: Re: Bad PHP error

From: Date: Sat, 27 Nov 2004 20:21:47 +0000
Subject: Re: Re: Bad PHP error
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-202968@lists.php.net to get a copy of this message
M. Sokolewicz wrote:
Octavian Rasnita wrote:
Hi all, I have tried the following script: $val = 10000000000; if (is_int($val)) { echo $val; } else { echo "$val is not an integer\n"; } The answer is: 10000000000 is not an integer. Why does this happen? I use PHP 5. Isn't PHP able to work with values like 10 billion? Do I need to use a certain special class for dealing with big numbers? How can I use that class? Thank you. Teddy
reply it's treated as a double since integers have a max value of (-2e32 +1 up to) 2e32-1, which is 4,294,967,296 (4 billion and some).
This would be for unsigned integers. PHP knows only signed integers, however. So the limit is 2147483648 However,
you shouldn't really see any difference in working, it's just treated as a double inside (a double float, that is). Which means it'll be written like 1.0e10 internally


« previous php.general (#202968) next »