From: Ilia Alshanetsky Date: Sun, 8 Aug 2010 15:45:02 +0000 (+0000) Subject: Additional fix for bug #52550 & fix test & warning from previous fixes X-Git-Tag: php-5.4.0alpha1~191^2~1131 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9af17b839a992322d43efcfa89e5ca70624c3a7;p=php Additional fix for bug #52550 & fix test & warning from previous fixes --- diff --git a/ext/standard/math.c b/ext/standard/math.c index accddaa0bb..5c758d2878 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -29,6 +29,8 @@ #include #include +#include "basic_functions.h" + /* {{{ php_intlog10abs Returns floor(log10(fabs(val))), uses fast binary search */ static inline int php_intlog10abs(double value) { @@ -127,7 +129,11 @@ PHPAPI double _php_math_round(double value, int places, int mode) { double tmp_value; int precision_places; - precision_places = 14 - php_intlog10abs(value); + if ((precision_places = php_intlog10abs(value)) > 0) { + precision_places = 14 - php_intlog10abs(value); + } else { + precision_places = 14; + } f1 = php_intpow10(abs(places)); diff --git a/ext/standard/tests/math/log_variation2.phpt b/ext/standard/tests/math/log_variation2.phpt index 00b3b316dc..327e7c5b9b 100644 --- a/ext/standard/tests/math/log_variation2.phpt +++ b/ext/standard/tests/math/log_variation2.phpt @@ -94,7 +94,7 @@ Warning: log(): base must be greater than 0 in %s on line %d bool(false) -- Iteration 2 -- -float(INF) +float(NAN) -- Iteration 3 -- float(0.12145441273706) @@ -135,7 +135,7 @@ Warning: log(): base must be greater than 0 in %s on line %d bool(false) -- Iteration 13 -- -float(INF) +float(NAN) -- Iteration 14 -- @@ -143,7 +143,7 @@ Warning: log(): base must be greater than 0 in %s on line %d bool(false) -- Iteration 15 -- -float(INF) +float(NAN) -- Iteration 16 --