|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-26 17:11 UTC] johannes@php.net
[2007-03-28 13:35 UTC] info at e-mhd dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 15:00:01 2025 UTC |
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