Bug #53045 [Opn]: broken result of intval()
| From: | rasmus@php.net | Date: | Tue, 12 Oct 2010 17:06:40 +0000 |
| Subject: | Bug #53045 [Opn]: broken result of intval() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-155113@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53045&edit=1
ID: 53045
Updated by: rasmus@php.net
Reported by: remy at wh dot nl
Summary: broken result of intval()
Status: Open
Type: Bug
Package: *Math Functions
Operating System: FreeBSD
PHP Version: 5.2.14
Block user comment: N
New Comment:
Only a problem on 32-bit systems I assume? I can't reproduce it here,
but all my
stuff is 64-bit.
Previous Comments:
------------------------------------------------------------------------
[2010-10-12 18:34:15] remy at wh dot nl
Description:
------------
intval(log(8,2)) gives 2 as result, expected 3
Test script:
---------------
<?php
$maxrounds = log(8, 2);
echo 'test:'.$maxrounds."\n";
echo 'test:'.log(8,2)."\n";
echo 'intval:'.intval(3.0000)."\n";
echo 'intval:'.intval(log(8,2))."\n";
echo 'intval:'.intval($maxrounds)."\n";
echo 'intval+1:'.(intval($maxrounds)+1)."\n";
echo 'intval+1:'.intval($maxrounds+1)."\n";
echo 'intval+1:'.intval($maxrounds + 1)."\n";
echo 'sprintf dec:'.sprintf('%d', $maxrounds)."\n";
echo 'sprintf float:'.sprintf('%f', $maxrounds)."\n";
echo 'sprintf float non-locale:'.sprintf('%F', $maxrounds)."\n";
var_dump($maxrounds)."\n";
?>
Expected result:
----------------
test:3
test:3
intval:3
intval:3
intval:3
intval+1:4
intval+1:4
intval+1:4
sprintf dec:3
sprintf float:3.000000
sprintf float non-locale:3.000000
float(3)
Actual result:
--------------
test:3
test:3
intval:3
intval:2
intval:2
intval+1:3
intval+1:3
intval+1:3
sprintf dec:2
sprintf float:3.000000
sprintf float non-locale:3.000000
float(3)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53045&edit=1