php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41045 intval returns different values, depending on the PHP version
Submitted: 2007-04-11 01:31 UTC Modified: 2007-04-11 21:13 UTC
From: xris01 at free dot fr Assigned:
Status: Not a bug Package: Math related
PHP Version: 5.2.1 OS: Debian Sarge
Private report: No CVE-ID: None
 [2007-04-11 01:31 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-11 13:58 UTC] tony2001@php.net
A bug has been fixed, the behaviour has changed.
 [2007-04-11 21:13 UTC] xris01 at free dot fr
Please, can you precise what does it mean ?
The next 5.2.1.x release will contain a fix ?

thanks.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Feb 24 21:01:26 2020 UTC