# [PATCH] rounding fuzz fix for recent gcc

- Thread: https://externals.io/message/12498
- Original archive: https://news-web.php.net/php.internals/12498
- Started by Joe Orton on 2004-08-31T09:34:25+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #12498 — Joe Orton — 2004-08-31T09:34:25+00:00

URL: https://externals.io/message/12498#12498

gcc 3.4.x on x86 optimises the configure test for whether rounding
"fuzz" is needed such that the test result flips from true to false,
unlike previous gcc releases.  The bug24142.t tests for PHP `round()` then
fails, so I presume this is a real problem.

Out-of-line-ing the code a little works around this by preventing an
inline `floor()` from being used.

--- 4.3/ext/standard/config.m4	10 May 2004 07:25:11 -0000	1.47.2.14
+++ 4.3/ext/standard/config.m4	19 Aug 2004 13:55:54 -0000
@@ -234,8 +234,11 @@
 AC_MSG_CHECKING([whether rounding works as expected])
 AC_TRY_RUN([
 #include <math.h>
+  double my_floor(double n) {
+    return floor(n*pow(10,2) + 0.5);
+  }
   int main() {
-    return floor(0.045*pow(10,2) + 0.5)/10.0 != 0.5;
+    return my_floor(0.045)/10.0 != 0.5;
   }
 ],[
   PHP_ROUND_FUZZ=0.5
