On Tue, 14 Aug 2018 15:23:01, Corinna Vinschen wrote:
I just wonder why returning -NaN when the input is "-nan" isn't the
better approach. After all:
printf ("nan (\"\") =3D %f\n", nan (""));
printf ("-nan (\"\") =3D %f\n", -nan (""));
=3D=3D>
nan ("") =3D nan
-nan ("") =3D -nan
So, shouldn't the ideal outcome be this:
strtod ("nan", NULL) =3D nan
strtod ("-nan", NULL) =3D -nan
strtold ("nan", NULL) =3D nan
strtold ("-nan", NULL) =3D -nan
a number can be positive or negative. as "NaN" is by definition not a number,
it cannot be positive or negative, it is simply itself, something anathema to
a number.
The only case where "-nan" would be acceptable is the string case, but even in
that instance it is still not negative, it is merely a string that happens to
start with "hyphen-minus" U+002D, and has no bearing on a sign, just as a string
can have no sign.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple