|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-09-22 16:18 UTC] tony2001@php.net
[2005-09-22 21:16 UTC] osolo at wndtabs dot com
[2005-09-22 21:43 UTC] sniper@php.net
[2005-09-23 10:03 UTC] sniper@php.net
[2005-09-26 17:59 UTC] osolo at wndtabs dot com
[2005-09-26 18:07 UTC] sniper@php.net
[2005-09-26 21:13 UTC] osolo at wndtabs dot com
[2005-12-24 02:13 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 22:00:01 2025 UTC |
Description: ------------ The round() function will return inconsistent results when PHP is compiled under certain Linux distro/CPU/compiler combinations. For example, if when compiling PHP on Gentoo 1.12.0_pre6/cc 3.4.4/Pentium 4, we get: round(0.245,2) => 0.24 Instead of the expected 0.25. I've traced the problem to the PHP_ROUND_WITH_FUZZ macro in ext/standard/math.c. This macro starts out as: #define PHP_ROUND_WITH_FUZZ(val, places) { \ double tmp_val=val, f = pow(10.0, (double) places); \ ... Changing the first line to: volatile double tmp_val=val; double f = pow(10.0, (double) places); \ I suspect the problem is that the optimizer is keeping tmp_val in a floating point register that has a difference precision than a C double. Declaring it volatile keeps it in the variable and makes things more consisntant.