Fix strtof ("-nan") returns positive NaN
strtof ("-nan") returned positive NaN instead of negative NaN. strtod ("-nan") and strtold ("-nan") return negative NaN. Linux glibc has been fixed that strto{f|d|ld} ("-nan") returns negative NaN. https://sourceware.org/bugzilla/show_bug.cgi?id=23007 This commit makes strtof preserves the negative sign bit when parsing "-nan" like glibc.
This commit is contained in:
parent
4c8fa88e4d
commit
c8d4c99ecd
|
@ -1289,7 +1289,7 @@ strtof_l (const char *__restrict s00, char **__restrict se, locale_t loc)
|
||||||
{
|
{
|
||||||
double val = _strtod_l (_REENT, s00, se, loc);
|
double val = _strtod_l (_REENT, s00, se, loc);
|
||||||
if (isnan (val))
|
if (isnan (val))
|
||||||
return nanf (NULL);
|
return signbit (val) ? -nanf (NULL) : nanf (NULL);
|
||||||
float retval = (float) val;
|
float retval = (float) val;
|
||||||
#ifndef NO_ERRNO
|
#ifndef NO_ERRNO
|
||||||
if (isinf (retval) && !isinf (val))
|
if (isinf (retval) && !isinf (val))
|
||||||
|
@ -1304,7 +1304,7 @@ strtof (const char *__restrict s00,
|
||||||
{
|
{
|
||||||
double val = _strtod_l (_REENT, s00, se, __get_current_locale ());
|
double val = _strtod_l (_REENT, s00, se, __get_current_locale ());
|
||||||
if (isnan (val))
|
if (isnan (val))
|
||||||
return nanf (NULL);
|
return signbit (val) ? -nanf (NULL) : nanf (NULL);
|
||||||
float retval = (float) val;
|
float retval = (float) val;
|
||||||
#ifndef NO_ERRNO
|
#ifndef NO_ERRNO
|
||||||
if (isinf (retval) && !isinf (val))
|
if (isinf (retval) && !isinf (val))
|
||||||
|
|
Loading…
Reference in New Issue