From:             
Operating system: FreeBSD
PHP version:      5.2.14
Package:          *Math Functions
Bug Type:         Bug
Bug description:broken result of intval()

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 bug report at http://bugs.php.net/bug.php?id=53045&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=53045&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=53045&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=53045&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=53045&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=53045&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=53045&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=53045&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=53045&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=53045&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=53045&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=53045&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=53045&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=53045&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=53045&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=53045&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=53045&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=53045&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=53045&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=53045&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=53045&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=53045&r=mysqlcfg

Reply via email to