From:             
Operating system: Multiple
PHP version:      5.3.2
Package:          Scripting Engine problem
Bug Type:         Bug
Bug description:Wrong results with float arithmetics

Description:
------------
When calculating with and rounding float values, the result of the
calculation is wrong.



This bug seems to affect multiple versions of php. I have tested it with
PHP 5.3.2 (Fedora 12), PHP 5.2.6 (Red Hat), PHP 5.3.0 (Windows XP).

Test script:
---------------
echo floor(138.95 * 100), "\n";

echo floor(141.95 * 100), "\n";

echo floor(142.95 * 100), "\n";



echo intval(142.95 * 100), "\n";

echo (int)(138.95 * 100);

Expected result:
----------------
13895

14195

14295

14295

13895

Actual result:
--------------
13894

14194

14294

14294

13894

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

Reply via email to