#41045 [Opn->Bgs]: intval returns different values, depending on the PHP version
| From: | tony2001@php.net | Date: | Wed, 11 Apr 2007 13:58:56 +0000 |
| Subject: | #41045 [Opn->Bgs]: intval returns different values, depending on the PHP version | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-111348@lists.php.net to get a copy of this message | ||
ID: 41045
Updated by: tony2001@php.net
Reported By: xris01 at free dot fr
-Status: Open
+Status: Bogus
Bug Type: Math related
Operating System: Debian Sarge
PHP Version: 5.2.1
New Comment:
A bug has been fixed, the behaviour has changed.
Previous Comments:
------------------------------------------------------------------------
[2007-04-11 01:31:48] xris01 at free dot fr
Description:
------------
I understand that floats are expected to overflow when converted to
int.
What I don't, is why I don't have the same result on the same hardware
with 2 versions of PHP :
Reproduce code:
---------------
$var = -2302452860;
echo 'var_dump($var) = '; echo var_dump($var); echo "<br>";
echo '$var = '; echo $var; echo "<br>";
echo 'intval($var) = '; echo intval($var); echo "<br>";
On PHP 5.2.1, it returns :
var_dump($var) = float(-2302452860)
$var = -2302452860
intval($var) = -2147483648
On PHP 5.1.6, it returns :
var_dump($var) = float(-2302452860)
$var = -2302452860
intval($var) = 1992514436
Is there anyway to get, in any case, the truncated result ? Any php.ini
parameter ?
Thanks.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41045&edit=1