| www.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:from:to:subject:message-id:reply-to | |
| :references:mime-version:content-type:in-reply-to; q=dns; s= | |
| default; b=EI+Un7jJcNBhkwLm4j2AjkkjjvxQp1CgRtIW2Im3WWDof20+VMfMe | |
| 8jQNs6M4LyK03xKYRGEuI3BvMGAixYgF6Vt0wJNmLZmZnt37LdxLC8qip6u3QNKm | |
| TqGCTFBCsxMc/rqIgOkwfamOw0YYpnepa+FLhmf5Ywo1ugR3SaXSpM= | |
| 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:from:to:subject:message-id:reply-to | |
| :references:mime-version:content-type:in-reply-to; s=default; | |
| bh=li+UyGt/L0psmrSgE1BQ7i2T6DQ=; b=gsh5K1QppDZJrzNMKCx+SwTkOZN/ | |
| NXIgK1rheBNWHQzVrsrYIjpfvEkX5MbjTULLn3apTpA6XRu2j0+GCda2n1A6EyNQ | |
| RxkvuIX5F3IaCuwcoyzOzsVoX/4cqu0NfRzLVAQ9ue7ERBuSKyYrey2dKi0oluJk | |
| HVBINtvaIh7Iiew= | |
| 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=-105.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= |
| X-HELO: | mout.kundenserver.de |
| Date: | Tue, 14 Aug 2018 15:23:01 +0200 |
| From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: strtod ("nan") returns negative NaN |
| Message-ID: | <20180814132301.GX3747@calimero.vinschen.de> |
| Reply-To: | cygwin AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| References: | <20180814095618 DOT GT3747 AT calimero DOT vinschen DOT de> <20180814095618_dot_GT3747_at_calimero_dot_vinschen_dot_de> <20180814103900 DOT GU3747 AT calimero DOT vinschen DOT de> <20180814 DOT 211757 DOT 2066454831159853501 DOT trueroad AT trueroad DOT jp> |
| MIME-Version: | 1.0 |
| In-Reply-To: | <20180814.211757.2066454831159853501.trueroad@trueroad.jp> |
| User-Agent: | Mutt/1.9.2 (2017-12-15) |
--iiZKCn1f/U0ES2iY
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Aug 14 21:17, Masamichi Hosoda wrote:
> > On Aug 14 11:56, Corinna Vinschen wrote:
> >> On Aug 14 13:45, Masamichi Hosoda wrote:
> >> > >From a50ee5a4747a99c70469a53fe959f3dc22d3b79a Mon Sep 17 00:00:00 2=
001
> >> > From: Masamichi Hosoda <trueroad AT trueroad DOT jp>
> >> > Date: Tue, 14 Aug 2018 12:50:32 +0900
> >> > Subject: [PATCH] Fix strtod ("nan") returns qNaN
> >> >=20
> >> > The definition of qNaN for x86_64 and x86 was wrong.
> >> > So strtod ("nan") returned sNaN instead of qNaN.
> >> >=20
> >> > Furthermore, it was inverted the sign bit with the presence of `-` c=
haracter.
> >> > So strtod ("-nan") returned qNaN.
> >> >=20
> >> > 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(-)
> >> [...]
> > With your patch, strtold looks more correct, but it still prints the
> > sign of NaN:
> >=20
> > strtod ("nan", NULL) =3D nan
> > strtod ("-nan", NULL) =3D nan
> > strtold ("nan", NULL) =3D nan
> > strtold ("-nan", NULL) =3D -nan
> > nan ("") =3D nan
> >=20
> > Question: What's wrong with that? Wouldn't it be more correct if
> > strtod returns -NaN for "-nan" as well?
>=20
> In my investigate,
> strtold sets sign bit when parameter has '-' character.
> The wrong long double NaN definition is negative NaN that is set sign bit.
> So without my patch, both strtold ("nan") and
> strtold ("-nan") return negative NaN.
>=20
> On the other hand, strtod inverts the sign when parameter has '-' charact=
er.
> The wrong double NaN definition is negative NaN.
> So without my patch, strtod ("nan") returns negative NaN
> and strtod ("-nan") returns positive NaN.
Your patch improves the situation, that's a sure thing and I did not
question that.
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
?
Corinna
--=20
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--iiZKCn1f/U0ES2iY
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlty17UACgkQ9TYGna5E
T6Cy3hAAmuRD5bUBHHaPFhtZQ+XoTATfTfHp4ue8viKCE4D027DZLGIKvnIAeyBc
qyKGF0ph7zDAS9hNq237f50wifRRm7ZHieWB6906LyvbsUGAwDWxSR8FdON3rG/O
bsfBMirs33owZfM/aYtilIa4+q/TNBRqA4t5D1ZZzGmYc957PU0FhO51lN2EBMXb
XvREcKsNIlBwjoYU5LeoWXuNG6pUGLqwcAO2YJyz4eln1/EIBE5p/gemPcrDl429
lJa35ByZGTyOfagEb9RD6+IAxXn9I6axfalX43zsF+7lVksvFD+JltsbZeW9O51f
huOjN6cyni+flr4BN7P5QVxOVhTCyEFk/PUO+KVHxpChfOdxqEyzWioBXSxa8Hub
fXIwlnx1EP7faiYxIUyO2IQPYhZwhKX8EZ6IuU3hIxqA0WDfZ1bbMbpmKlwtXdI2
ICZPuT2d9E2KtRacmesVvZilqU3hRjNTko9UX3+Y3a48Jwc1WzXdHwdlEWQx5yBG
atx6g/VcDGX3TRnRmtvZDBFCFnLimY7Q8bIlWXU41Sg9NOVkPegTr0VNWuU622Ww
zxi7zLKywsHN0dWyUNJ3aILrM2HeTj6E6xUdhIoxTePvtQLdu+xHDLW4N2vP0sk2
bq5hHr1wDTo0/RA6wODSKAi85ejVdy+3eE5s3kBL8qPeIoStfpY=
=kPie
-----END PGP SIGNATURE-----
--iiZKCn1f/U0ES2iY--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |