iliaa           Fri Aug  8 19:42:10 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src/ext/standard       math.c 
  Log:
  MFH: Avoid a round() bug that occurs due to over optimization of C code by 
  gcc.
  
  
Index: php-src/ext/standard/math.c
diff -u php-src/ext/standard/math.c:1.97.2.4 php-src/ext/standard/math.c:1.97.2.5
--- php-src/ext/standard/math.c:1.97.2.4        Thu Jan 16 08:21:54 2003
+++ php-src/ext/standard/math.c Fri Aug  8 19:42:10 2003
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: math.c,v 1.97.2.4 2003/01/16 13:21:54 edink Exp $ */
+/* $Id: math.c,v 1.97.2.5 2003/08/08 23:42:10 iliaa Exp $ */
 
 #include "php.h"
 #include "php_math.h"
@@ -32,6 +32,8 @@
 #define M_PI 3.14159265358979323846
 #endif
 
+#define PHP_ROUND_FUZZ 0.50000000001
+
 /* {{{ proto int abs(int number)
    Return the absolute value of the number */
 
@@ -143,9 +145,9 @@
 
                        return_val *= f;
                        if (return_val >= 0.0)
-                               return_val = floor(return_val + 0.5);
+                               return_val = floor(return_val + PHP_ROUND_FUZZ);
                        else
-                               return_val = ceil(return_val - 0.5);
+                               return_val = ceil(return_val - PHP_ROUND_FUZZ);
                        return_val /= f;
 
                        RETURN_DOUBLE(return_val);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to