From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73458 invoked by alias); 14 Aug 2018 17:12:39 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 73448 invoked by uid 89); 14 Aug 2018 17:12:39 -0000 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 Received: from mail-oi0-f67.google.com (HELO mail-oi0-f67.google.com) (209.85.218.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Aug 2018 17:12:37 +0000 Received: by mail-oi0-f67.google.com with SMTP id m11-v6so35028210oic.2 for ; Tue, 14 Aug 2018 10:12:37 -0700 (PDT) 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== Return-Path: Received: from Wyw ([2605:6000:9fc0:56:cc81:ec52:ab35:2fe4]) by smtp.gmail.com with ESMTPSA id e125-v6sm52223203oig.4.2018.08.14.10.12.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 10:12:34 -0700 (PDT) Message-ID: <5b730d82.1c69fb81.f063b.d706@mx.google.com> Date: Tue, 14 Aug 2018 19:24:00 -0000 From: Steven Penny 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) X-SW-Source: 2018-08/txt/msg00186.txt.bz2 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