Re: strtod ("nan") returns negative NaN
On 2018-08-14 15:44, Eric Blake wrote:
> On 08/14/2018 04:31 PM, Stephen John Smoogen wrote:
>>> The C standard disagrees with you [ISO:IEC 9899:2011, section 18.104.22.168.2]:
>>> "An implementation may give zero and values that are not floating-point
>>> numbers (such as infinities and NaNs) a sign or may leave them unsigned.
>>> Wherever such values are unsigned, any requirement in this International
>>> Standard to retrieve the sign shall produce an unspecified sign, and any
>>> requirement to set the sign shall be ignored."
> Cygwin is indeed buggy for turning "NaN" into -NaN; that's easy enough to fix.
> The remaining question is whether it should turn "-NaN" into -NaN; and the
> argument that glibc JUST fixed their bug 23007 to make strtod("-nan") return
> -NaN means that Cygwin should, indeed, preserve the negative sign bit when
> parsing "-nan".
> So, the desired behavior:
> strtod("nan") -> NaN
> strtod("-nan") -> -NaN
> printf("%f", NaN) -> "NaN"
> printf("%f", -NaN) -> "-NaN"
> and similarly for float and long double
and wcstod, wcstod, wcstold functions.
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple