delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT 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:date:message-id:to:cc:subject:from:in-reply-to | |
:references:mime-version:content-type:content-transfer-encoding; | |
q=dns; s=default; b=C7MDRlDW3F63xxcpeaM8nu5l/77VIylAMJFz58hdO4r | |
cFpa9bTVDBmVdt+fdswe20u0G/H7D8tCNSiMnDLDbZCw1g9rZNDeQw17M87vennN | |
VBwhYmwBJVDu67gINA4tNrly7FmNUnAijXNL2DJOKGKnEEeswA+j7UYOI0wuvFzY | |
= | |
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:date:message-id:to:cc:subject:from:in-reply-to | |
:references:mime-version:content-type:content-transfer-encoding; | |
s=default; bh=VmbYzX5MbPlrYyL9S99pR+U5ydY=; b=fVdRTlfMQZ1fcuR2z | |
IhuYjruu1LPSverSQs/HPmCCiLAsMFjrrAmANXn0aWBtSXW5nCIwhX2Mf276+zcB | |
TU56KDg5K8pNq5lB73Y1XLiBGS+IhsbrHX/y1kPWXfMPZotYYye6TFKor6V1Zq74 | |
YZmu+K4q5MxuUPmSCxycrYKDNk= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Spam-SWARE-Status: | No, score=-23.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=4516, H*UA:version, H*x:version, inversion |
X-HELO: | msc14.plala.or.jp |
Date: | Tue, 14 Aug 2018 13:45:27 +0900 (JST) |
Message-Id: | <20180814.134527.917341694729989717.trueroad@trueroad.jp> |
To: | cygwin AT cygwin DOT com |
Cc: | trueroad AT trueroad DOT jp |
Subject: | Re: strtod ("nan") returns negative NaN |
From: | Masamichi Hosoda <trueroad AT trueroad DOT jp> |
In-Reply-To: | <20180814.113135.1571893395887584078.trueroad@trueroad.jp> |
References: | <CANnLRdii8mX71D936AhhEYm+S0s4gS5RGgpPhV_rB6=kzmXKsw AT mail DOT gmail DOT com> <20180814 DOT 100952 DOT 1684125661222835312 DOT trueroad AT trueroad DOT jp> <20180814 DOT 113135 DOT 1571893395887584078 DOT trueroad AT trueroad DOT jp> |
Mime-Version: | 1.0 |
X-VirusScan: | Outbound; mvir-ac14; Tue, 14 Aug 2018 13:45:36 +0900 |
----Next_Part(Tue_Aug_14_13_45_27_2018_543)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>> On Mon, 13 Aug 2018 at 19:46, Duncan Roe <duncan_roe AT optusnet DOT com DOT au> wrote: >>>> >>>> On Mon, Aug 13, 2018 at 12:52:48PM -0400, Stephen John Smoogen wrote: >>>> > On Mon, 13 Aug 2018 at 11:16, Masamichi Hosoda <trueroad AT trueroad DOT jp> wrote: >>>> [...] >>>> > On Fedora 27 with 7.3.1 it gives >>>> > ``` >>>> > stod ("nan") = nan >>>> > stod ("-nan") = nan >>>> > quiet_NaN () = nan >>>> > ``` [...] >> Cygwin 2.10.0 64 bit with gcc 7.3.0 >> ``` >> strtod ("nan", NULL) = -nan >> strtod ("-nan", NULL) = nan >> nan ("") = nan >> ``` >> >> Ubuntu 16.04 LTS 64 bit with gcc 5.4.0 >> ``` >> strtod ("nan", NULL) = nan >> strtod ("-nan", NULL) = nan >> nan ("") = nan >> ``` I've created the quick hack patch that fixes `strtod ()`. On Cygwin 64 bit with the patch, result of foobar.c: ``` strtod ("nan", NULL) = nan strtod ("-nan", NULL) = nan nan ("") = nan ``` Also result of foobar.cc: ``` stod ("nan") = nan stod ("-nan") = nan quiet_NaN () = nan ``` ----Next_Part(Tue_Aug_14_13_45_27_2018_543)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-Fix-strtod-nan-returns-qNaN.patch" From a50ee5a4747a99c70469a53fe959f3dc22d3b79a Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda <trueroad AT trueroad DOT jp> Date: Tue, 14 Aug 2018 12:50:32 +0900 Subject: [PATCH] Fix strtod ("nan") returns qNaN The definition of qNaN for x86_64 and x86 was wrong. So strtod ("nan") returned sNaN instead of qNaN. Furthermore, it was inverted the sign bit with the presence of `-` character. So strtod ("-nan") returned qNaN. This commit fixes definition of qNaN and removes the sign bit inversion when evaluating "nan". --- newlib/libc/stdlib/gd_qnan.h | 8 ++++---- newlib/libc/stdlib/strtod.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/newlib/libc/stdlib/gd_qnan.h b/newlib/libc/stdlib/gd_qnan.h index b775f82..3ca337b 100644 --- a/newlib/libc/stdlib/gd_qnan.h +++ b/newlib/libc/stdlib/gd_qnan.h @@ -26,18 +26,18 @@ #elif defined(__IEEE_LITTLE_ENDIAN) #if !defined(__mips) -#define f_QNAN 0xffc00000 +#define f_QNAN 0x7fc00000 #define d_QNAN0 0x0 -#define d_QNAN1 0xfff80000 +#define d_QNAN1 0x7ff80000 #define ld_QNAN0 0x0 #define ld_QNAN1 0xc0000000 -#define ld_QNAN2 0xffff +#define ld_QNAN2 0x7fff #define ld_QNAN3 0x0 #define ldus_QNAN0 0x0 #define ldus_QNAN1 0x0 #define ldus_QNAN2 0x0 #define ldus_QNAN3 0xc000 -#define ldus_QNAN4 0xffff +#define ldus_QNAN4 0x7fff #elif defined(__mips_nan2008) #define f_QNAN 0x7fc00000 #define d_QNAN0 0x0 diff --git a/newlib/libc/stdlib/strtod.c b/newlib/libc/stdlib/strtod.c index 0cfa9e6..3b9fd26 100644 --- a/newlib/libc/stdlib/strtod.c +++ b/newlib/libc/stdlib/strtod.c @@ -451,6 +451,7 @@ _strtod_l (struct _reent *ptr, const char *__restrict s00, char **__restrict se, #ifndef No_Hex_NaN } #endif + sign = 0; goto ret; } } -- 2.17.0 ----Next_Part(Tue_Aug_14_13_45_27_2018_543)-- Content-Type: text/plain; charset=us-ascii -- 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 ----Next_Part(Tue_Aug_14_13_45_27_2018_543)----
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |