Re: Bug #14134 Updated: Literal -2147483648 should be an int, not a double.
| From: | Derick Rethans | Date: | Tue, 20 Nov 2001 08:52:02 +0000 |
| Subject: | Re: Bug #14134 Updated: Literal -2147483648 should be an int, not a double. | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-71025@lists.php.net to get a copy of this message | ||
On Tue, 20 Nov 2001, Pierre-Alain Joye wrote:
> > When assigning the value -2147483648 to a variable, the variable becomes a double, even
> > though the value is within the range of integers. In fact, assigning -2147483647 - 1 works, as does
> > using intval("-2147483648").
> >
> > The following script demonstrates, and can be accessed at
> > <http://www.randomsample.org/tests/test-int-min.php>.
> >
> > <?php
> > $int_max = 2147483647;
> > $int_min = -2147483648;
> > $int_min_alt = -2147483647 - 1;
>
> 2^31 = 2147483647
> If I m not wrong, php code integer on 32bits, 1 bit for the sign, interval will be -2147483647
> (2^31).
> As the docs say, double will be used for larger integer values.
You're not correct, the smallest number that should fit in into a signed
integer is -2147483648. -(2^31) The highest number is 2147483647. (2^31) - 1
Derick
---------------------------------------------------------------------
PHP: Scripting the Web - www.php.net - derick@php.net
SRM: Site Resource Manager - www.vl-srm.net
---------------------------------------------------------------------