ID:               40924
 User updated by:  info at e-mhd dot com
 Reported By:      info at e-mhd dot com
-Status:           Bogus
+Status:           Closed
 Bug Type:         Performance problem
 Operating System: Win & Linux
 PHP Version:      5.2.1
 New Comment:

Thank you for your reply.


Previous Comments:
------------------------------------------------------------------------

[2007-03-26 17:11:02] [EMAIL PROTECTED]

Floating point values have a limited precision. Hence a value might 
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly 
printing it without any mathematical operations.

If you would like to know more about "floats" and what IEEE
754 is read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
 
Thank you for your interest in PHP.

.

------------------------------------------------------------------------

[2007-03-26 16:52:36] info at e-mhd dot com

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 this bug report at http://bugs.php.net/?id=40924&edit=1

Reply via email to