#24381 [Com]: Inconsistence behavior of var_dump
| From: | marcot at tabini dot ca | Date: | Sun, 29 Jun 2003 02:51:44 +0000 |
| Subject: | #24381 [Com]: Inconsistence behavior of var_dump | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-42705@lists.php.net to get a copy of this message | ||
ID: 24381
Comment by: marcot at tabini dot ca
Reported By: yipkeikwok at yahoo dot com
Status: Bogus
Bug Type: Math related
Operating System: Windows 2000, Redhat Linux 9
PHP Version: 4.3.2
New Comment:
It actually *is* expected (albeit possibly incorrect) behaviour on
behalf of the engine:
http://bugs.php.net/bug.php?id=14134
Basically, what's happening is that
$int1 = -2147483648;
is being interpreted as
$int1 = 0 - 2147483648;
Since 2147483648 cannot be represented as an integer value, it (and,
therefore, the result of the expression) is converted to double.
Previous Comments:
------------------------------------------------------------------------
[2003-06-28 19:20:14] yipkeikwok at yahoo dot com
If the lower bound for the type "integer" is -2147483648, then,
according to
http://www.php.net/manual/en/language.types.integer.php
,var_dump() should have returned -2147483648 as int-typed instead of
float-typed.
The actual result now is
float(-2147483648)
--Yipkei Kwok
Integer overflow
If you specify a number beyond the bounds of the integer type, it will
be interpreted as a float instead. Also, if you perform an operation
that results in a number beyond the bounds of the integer type, a float
will be returned instead.
------------------------------------------------------------------------
[2003-06-28 19:05:07] pollita@php.net
Your "expected result" is based on an incorrect assumption.
The lower bound for type "integer" on a 32bit platform is in fact
-2147483648.
------------------------------------------------------------------------
[2003-06-28 18:51:35] yipkeikwok at yahoo dot com
Description:
------------
The function var_dump() returns different data type for -2147483647 and
-2147483647-1
--Yipkei Kwok
Reproduce code:
---------------
<?php
$int1 = -2147483648;
$int2 = -2147483647-1;
var_dump($int1);
var_dump($int2);
?>
Expected result:
----------------
float(-2147483648)
float(-2147483648)
The lower bound for data type integer is -2147483647. So, -2147483648
(-2147483647-1) should be regarded as float.
Actual result:
--------------
float(-2147483648)
int(-2147483648)
However, -2147483648 (-2147483647-1) is regarded as int.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24381&edit=1