From:             firealwaysworks at gmail dot com
Operating system: Linux
PHP version:      5.2.6
PHP Bug Type:     Math related
Bug description:  round()  errors. 

Description:
------------
In this example the multiplication of two floats yields a number with 5
significant figures.  The round() function incorrectly handles this number
only when it is working with the answer to a mathematical operation.  It is
important to note that the round() function is working properly for static
values. 

I found this because I am writing financial software in PHP.   I have
absolutely no doubt that this bug would cause our company to loose money.

Reproduce code:
---------------
print 21.33*1.015."<br>";
print round(21.33*1.015,2)."<br>";
print round(21.33*1.015,4)."<br>";
print round(21.64995,4);

Expected result:
----------------
21.64995
21.65
21.65
21.65

Actual result:
--------------
21.64995
21.65
21.6499
21.65

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

Reply via email to