Mail Archives: cygwin/2018/08/14/06:39:16
--CPn8Wy5ME997YUMW
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Aug 14 11:56, Corinna Vinschen wrote:
> On Aug 14 13:45, Masamichi Hosoda wrote:
> > >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
> >=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 `-` char=
acter.
> > 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(-)
>=20
> Can you please send this patch to the newlib AT sourceware DOT org
> mailing list? As soon as something in newlib gets changed, a lot of
> other targets are affected and the guys working on those targets should
> have a chance to chime in.
Looks like strtold is affected as well, just differently:
printf ("strtod (\"nan\", NULL) =3D %f\n", strtod ("nan", NULL));
printf ("strtod (\"-nan\", NULL) =3D %f\n", strtod ("-nan", NULL));
printf ("strtold (\"nan\", NULL) =3D %Lf\n", strtold ("nan", NULL));
printf ("strtold (\"-nan\", NULL) =3D %Lf\n", strtold ("-nan", NULL));
printf ("nan (\"\") =3D %f\n", nan (""));
=3D=3D>
strtod ("nan", NULL) =3D -nan
strtod ("-nan", NULL) =3D nan
strtold ("nan", NULL) =3D -nan
strtold ("-nan", NULL) =3D -nan
nan ("") =3D nan
so it prints always -nan.
With your patch, strtold looks more correct, but it still prints the
sign of NaN:
strtod ("nan", NULL) =3D nan
strtod ("-nan", NULL) =3D nan
strtold ("nan", NULL) =3D nan
strtold ("-nan", NULL) =3D -nan
nan ("") =3D nan
Question: What's wrong with that? Wouldn't it be more correct if
strtod returns -NaN for "-nan" as well?
Corinna
--=20
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
--CPn8Wy5ME997YUMW
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAltysUQACgkQ9TYGna5E
T6CQ4A/+K8ahRMB0MvaH/L50Ubi4YB922tK3A79BaCKFpA2Umn5Z1GvvOIPxnbBU
NyCTt8eyQ2QrZACMuPGNduYUxOPQOjqAi8v2yC0G5xourM9fey3UbCB4tUXJ5wok
s1msvGJ3NzoBmmTg+VIioEzQeY0MwYV54XbtNW1gCtWWwCpmxRWyGcrki5HBUABr
mvxjK5kysuqBTsF6aA6D8ukNP5vN5gvDSrRdHaYhjNQOyjuVqOGYxPf7dZnL/JAj
usRLOI6s1g/HCnwX2A/L07hN1waLMEFV/nqhGKYkyGLeXDd32FnBVH4csDoLdlAd
pC7NuigHncpoimDNukEFQfKBtmU4oq1Bt7dFShxWn52I7cTYLZ2Hcs6oBM7oEOsN
NIC/VIz2K0wqN94DPnZ2zCOeHowRQo6QlxU7IHJDdzby7Fvp/1YaF8ngJqkCbpDA
pff+D/TpD9JfzotX3CSDkndDfJdfoqEcpmtZzjGKHtw/yhjRemkijGyjBcvwz+bm
TimWjOIZqTUQQFigaSPW4hjHKU63Xn0nh+Qtc/gdcguGrGLI68m1yjWEmX3f8O1M
PKa7tf0+NwWnA1DX8Ia6XMHY4nXbTDyhAVyJ1Xk0TnYTt92xqHPgxnJLupDTBFcB
0RjMp8FXuRFu/zVbLR/XWEYIQXuptKzrXQ6dOxMVMdRuIz1DWvQ=
=0oFz
-----END PGP SIGNATURE-----
--CPn8Wy5ME997YUMW--
- Raw text -