--- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -141,7 +141,7 @@ double tmp_value; int precision_places; - if (!php_math_is_finite(value)) { + if (!php_math_is_finite(value) || value == 0.0) { return value; } @@ -153,7 +153,7 @@ /* If the decimal precision guaranteed by FP arithmetic is higher than the requested places BUT is small enough to make sure a non-zero value is returned, pre-round the result to the precision */ - if (precision_places > places && precision_places - places < 15) { + if (precision_places > places && precision_places - 15 < places) { int64_t use_precision = precision_places < INT_MIN+1 ? INT_MIN+1 : precision_places; f2 = php_intpow10(abs((int)use_precision));