cvs: php-src /ext/standard math.c
| From: | Ilia Alshanetsky | Date: | Fri, 08 Aug 2003 23:40:44 +0000 |
| Subject: | cvs: php-src /ext/standard math.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-23015@lists.php.net to get a copy of this message | ||
iliaa Fri Aug 8 19:40:44 2003 EDT
Modified files:
/php-src/ext/standard math.c
Log:
Avoid a round() bug that occurs due to over optimization of C code by gcc.
This bug was confirmed across multiple systems with gcc 2.95.3 & 3.X+
Index: php-src/ext/standard/math.c
diff -u php-src/ext/standard/math.c:1.104 php-src/ext/standard/math.c:1.105
--- php-src/ext/standard/math.c:1.104 Tue Jun 10 16:03:38 2003
+++ php-src/ext/standard/math.c Fri Aug 8 19:40:44 2003
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: math.c,v 1.104 2003/06/10 20:03:38 imajes Exp $ */
+/* $Id: math.c,v 1.105 2003/08/08 23:40:44 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);