| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Jim Winstead <jimw@php.net> |
- | Stig Sæther Bakken <ssb@php.net> |
+ | Stig Sæther Bakken <ssb@php.net> |
| Zeev Suraski <zeev@zend.com> |
| PHP 4.0 patches by Thies C. Arntzen <thies@thieso.net> |
+----------------------------------------------------------------------+
}
/* }}} */
+/* {{{ php_math_is_finite */
+static inline int php_math_is_finite(double value) {
+#if defined(PHP_WIN32)
+ return _finite(value);
+#elif defined(isfinite)
+ return isfinite(value);
+#else
+ return value == value && (value == 0. || value * 2. != value);
+#endif
+}
+/* }}} */
+
/* {{{ 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) {
double tmp_value;
int precision_places;
- if ((precision_places = php_intlog10abs(value)) > 0) {
- precision_places = 14 - php_intlog10abs(value);
- } else {
- precision_places = 14;
+ if (!php_math_is_finite(value)) {
+ return value;
}
+
+ precision_places = 14 - php_intlog10abs(value);
f1 = php_intpow10(abs(places));