X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:to:subject:references
	:content-type; q=dns; s=default; b=IPpVGb3T/ivZ2hHz7R5Pz50bg+2L/
	t3XzjJxAC5+6tSifaSPuM5Fct4Wnyhg08CYbMSuN9hwRfmudc3cKvNtf4XM8T5h5
	ctPaJE7xRuZA91h0R4hYwApU9QAlkzXftOEQjZeKCrcsNyw8vSjJR7eE87EPxLs/
	yFD4WdMvtMcXIA=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:message-id:date:from:to:subject:references
	:content-type; s=default; bh=bvFg0kQCvNGVOB2q/ZYNoJzdWCU=; b=f3m
	SNlVq7hTs1/EdVhbCcIcECQnki/D8khigWhnebEt7KFrd8pAz7WqR95BxFySPIi/
	QtLX4V0I+3xq7W05oJafXdCfGuMVFBrH/0/0iC+tBSBFTmRbceXx931KXJIXM0Xz
	fEf10/TWJv07iPgVblZAl7QBqOVFsJffylBp05dQ=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*M:1c69fb81, H*M:google
X-HELO: mail-oi0-f67.google.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=20161025;        h=message-id:date:from:to:subject:references:user-agent;        bh=rkFNsWZn7WFo12Nb2ENQETT6XSh7gzPEG5MNLOpnQT4=;        b=i/npJntewD2+vjM4RRP/kG6bARD8FrNmwRobF/XKVC2rXRAWOk+wNO/+cKi/fEDpny         +xDgbjWJK4wJBquf4fewJTpTsEMG+AWwPdi1Jj10KvFz3X2rQgTl9ePraGxZTqjyBMY4         C6xQghjsYncZY+0JuJgmjyVCJR0RU7NZ6/EkrPDWh7YG34YQoRSLklBkDqf1JcjZcW6S         IXkNmUvvBtDglX/SzCqBX5eCOup9VYxwy4lFs7PQ6ot0nFgtheFX2E/0bOqXlpuKcuua         NFCNIdaUV/QyvBs40ofCjDtTMntLji12tGmcdldA1dZP0bvCxJJzYqxlDtpzWWTT50JA         E9iA==
Message-ID: <5b730d82.1c69fb81.f063b.d706@mx.google.com>
Date: Tue, 14 Aug 2018 10:12:34 -0700 (PDT)
From: Steven Penny <svnpenn@gmail.com>
To: cygwin@cygwin.com
Subject: Re: strtod ("nan") returns negative NaN
References: <20180814132301.GX3747@calimero.vinschen.de>
Content-Type: text/plain; charset=utf8; format=flowed
User-Agent: Tryst/2.8.0 (cup.github.io/tryst)

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

