|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 - 20 = ?
Subscribe to this entry?

 [2007-04-11 01:31 UTC] xris01 at free dot fr
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 ?



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-11 13:58 UTC]
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 ?

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Aug 13 16:05:46 2022 UTC