strtod ("nan") returns negative NaN

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Aug 14 15:54:00 GMT 2018


On Aug 14 12:20, Heavenly Avenger wrote:
> On 8/14/2018 10:23 AM, Corinna Vinschen wrote:
> > I just wonder why returning -NaN when the input is "-nan" isn't the
> > better approach.  After all:
> > 
> >    printf ("nan (\"\") = %f\n", nan (""));
> >    printf ("-nan (\"\") = %f\n", -nan (""));
> > 
> > ==>
> > 
> >    nan ("") = nan
> >    -nan ("") = -nan
> > 
> > So, shouldn't the ideal outcome be this:
> > 
> >    strtod ("nan", NULL) = nan
> >    strtod ("-nan", NULL) = -nan
> >    strtold ("nan", NULL) = nan
> >    strtold ("-nan", NULL) = -nan
> > 
> > ?
> > 
> > Corinna
> > 
> I'd say it is not the better/best approach as, even though it makes sense,
> all other implementations or linux distributions treat it as a plain "nan".
> So anything written for linux will potentially break on cygwin, I am not
> sure this is the idea behind cygwin, right?

My point is, even the glibc printf prints a negative NaN as "-nan",
see above.  strtod/strtold returning a different NaN value looks
inconsistent.

Well, never mind.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20180814/8735dba7/attachment.sig>


More information about the Cygwin mailing list