Fix non-numbers printing (#6142)

# Please, somebody knowing about floats - check if there's more non-numbers
# seems we should check for all of them
This commit is contained in:
Stanislav Malyshev 2000-08-14 10:02:14 +00:00
parent 9e750e64b9
commit 97c200b170

View File

@ -252,6 +252,39 @@ php_sprintf_appenddouble(char **buffer, int *pos,
} else if (precision > MAX_FLOAT_PRECISION) {
precision = MAX_FLOAT_PRECISION;
}
if(
#if defined(HAVE_ISNAN)
isnan(number)
#elif defined(NAN)
number == NAN
#else
0
#endif
) {
sign = (number<0);
php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, padding,
alignment, precision, sign, 0);
return;
}
if(
#if defined(HAVE_ISISINF)
isinf(number)
#elif defined(HAVE_ISFINITE)
!isfinite(number)
#elif defined(HAVE_FINITE)
!finite(number)
#else
0
#endif
) {
sign = (number<0);
php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, padding,
alignment, precision, sign, 0);
return;
}
cvt = php_convert_to_decimal(number, precision, &decpt, &sign, (fmt == 'e'));
if (sign) {