summaryrefslogtreecommitdiff
path: root/ext/standard/math.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2009-03-18 10:18:10 +0000
committerDmitry Stogov <dmitry@php.net>2009-03-18 10:18:10 +0000
commit31c0af245e7601f3c3c870c20a57e9cf8634bb7b (patch)
tree38d551086ead5a5d7c84f70154028b712de5550e /ext/standard/math.c
parentd3b42700a0279bfcd58414799b81cd332d1fa08f (diff)
downloadphp-git-31c0af245e7601f3c3c870c20a57e9cf8634bb7b.tar.gz
Fixed floating point mathematic speed degradation (Christian)
Diffstat (limited to 'ext/standard/math.c')
-rw-r--r--ext/standard/math.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/ext/standard/math.c b/ext/standard/math.c
index b8a0b927d9..f1e1a42aeb 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -24,7 +24,6 @@
#include "php.h"
#include "php_math.h"
#include "zend_multiply.h"
-#include "zend_float.h"
#include <math.h>
#include <float.h>
@@ -94,10 +93,8 @@ static inline double php_intpow10(int power) {
/* {{{ php_round_helper
Actually performs the rounding of a value to integer in a certain mode */
static inline double php_round_helper(double value, int mode) {
- ZEND_FLOAT_DECLARE
double tmp_value;
- ZEND_FLOAT_ENSURE();
if (value >= 0.0) {
tmp_value = floor(value + 0.5);
if ((mode == PHP_ROUND_HALF_DOWN && value == (-0.5 + tmp_value)) ||
@@ -116,7 +113,7 @@ static inline double php_round_helper(double value, int mode) {
}
}
- ZEND_FLOAT_RETURN(tmp_value);
+ return tmp_value;
}
/* }}} */
@@ -126,13 +123,10 @@ static inline double php_round_helper(double value, int mode) {
* mode. For the specifics of the algorithm, see http://wiki.php.net/rfc/rounding
*/
PHPAPI double _php_math_round(double value, int places, int mode) {
- ZEND_FLOAT_DECLARE
double f1, f2;
double tmp_value;
int precision_places;
- ZEND_FLOAT_ENSURE();
-
precision_places = 14 - php_intlog10abs(value);
f1 = php_intpow10(abs(places));
@@ -163,7 +157,7 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
}
/* This value is beyond our precision, so rounding it is pointless */
if (fabs(tmp_value) >= 1e15) {
- ZEND_FLOAT_RETURN(value);
+ return value;
}
}
@@ -196,7 +190,7 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
}
}
- ZEND_FLOAT_RETURN(tmp_value);
+ return tmp_value;
}
/* }}} */