From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54035 invoked by alias); 20 Aug 2018 17:24:47 -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 54021 invoked by uid 89); 20 Aug 2018 17:24:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Brian, brian, Standard, Stephen X-HELO: smtp-out-so.shaw.ca Received: from smtp-out-so.shaw.ca (HELO smtp-out-so.shaw.ca) (64.59.136.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Aug 2018 17:24:44 +0000 Received: from [192.168.1.100] ([24.64.240.204]) by shaw.ca with ESMTP id rnuzfa1NcwyxUrnv0fn6tg; Mon, 20 Aug 2018 11:24:43 -0600 Reply-To: Brian.Inglis@SystematicSw.ab.ca Subject: Re: strtod ("nan") returns negative NaN To: cygwin@cygwin.com References: <20180814132301.GX3747@calimero.vinschen.de> <5b730d82.1c69fb81.f063b.d706@mx.google.com> <8636vgac6e.fsf@gmail.com> <06e75f75-6a5f-2140-7557-849290225f79@redhat.com> From: Brian Inglis Openpgp: preference=signencrypt Message-ID: <2b30e006-1679-791d-bb0e-9d7949fe005d@SystematicSw.ab.ca> Date: Tue, 21 Aug 2018 03:18:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <06e75f75-6a5f-2140-7557-849290225f79@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00275.txt.bz2 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 5.2.4.2.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". > https://sourceware.org/bugzilla/show_bug.cgi?id=23007 > 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 FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple