From: info at e-mhd dot com
Operating system: Win & Linux
PHP version: 5.2.1
PHP Bug Type: Performance problem
Bug description: round() precision problem
Description:
------------
Problem with function round()
rounded value is incorrect
Reproduce code:
---------------
ini_set("precision", 15);
bcscale(5);
$a1 = (string)(3845349 * 34.065);
$a2 = (float)(3845349 * 34.065);
$a3 = bcmul(3845349, 34.065);
echo "A1 = ";
var_dump($a1);
echo("<br />");
echo "A2 = ";
var_dump($a2);
echo("<br />");
echo "A3 = ";
var_dump($a3);
echo "<br />Values after round() :";
echo "<br />A1 = ".round( $a1 ,2);
echo "<br />A2 = ".round( $a2 ,2);
echo "<br />A3 = ".round( $a3 ,2);
Expected result:
----------------
A1 = string(13) "130991813.685"
A2 = float(130991813.685)
A3 = string(13) "130991813.685"
Values after round() :
A1 = 130991813.69
A2 = 130991813.69
A3 = 130991813.69
Actual result:
--------------
A1 = string(13) "130991813.685"
A2 = float(130991813.685)
A3 = string(13) "130991813.685"
Values after round() :
A1 = 130991813.69
A2 = 130991813.68
A3 = 130991813.69
--
Edit bug report at http://bugs.php.net/?id=40924&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=40924&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=40924&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=40924&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40924&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=40924&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40924&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40924&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40924&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40924&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40924&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=40924&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=40924&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40924&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40924&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40924&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40924&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40924&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40924&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40924&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40924&r=mysqlcfg