Re: [PATCH] Print sign of NaN values to nano-vfprintf.

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Dec 11 21:13, [email protected] wrote:
> > diff --git a/newlib/libc/stdio/nano-vfprintf_float.c
> b/newlib/libc/stdio/nano-vfprintf_float.c
> > index 98893e97b..071a09edc 100644
> > --- a/newlib/libc/stdio/nano-vfprintf_float.c
> > +++ b/newlib/libc/stdio/nano-vfprintf_float.c
> > @@ -213,6 +213,8 @@ _printf_float (struct _reent *data,
> >      }
> >    if (isnan (_fpvalue))
> >      {
> > +      if (_fpvalue < 0)
> > +	pdata->l_buf[0] = '-';
> >        if (code <= 'G')		/* 'A', 'E', 'F', or 'G'.  */
> >  	cp = "NAN";
> 
> This patch doesn't work, as a comparison of a NaN with anything should
> always return false. As per the main printf code, this can be done by
> checking the sign bit instead:
> 
> -      if (_fpvalue < 0)
> +      if (signbit (_fpvalue))
>  	pdata->l_buf[0] = '-';
> 
> Patch attached.

Pushed.


Thanks,
Corinna



-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlwSTbUACgkQ9TYGna5E
T6ACuA//RS2oWexoiGIuPh59nrYkOupsaNTBLs7t3NSLvHcQBrq+OJW7rxAiZO4N
Y4ELrIwEpaguRsK2DlT5tIEmkUjoxSZA6TqNLTHVAT8R9AlsbdAX3cJ5rO2nyewt
X5wY2uK+vL4L3D2WFXIsgAynYAtbSfNUFbHk7Y0vX8CGzhB5kswpwFIancOl2+e9
tYbk6B5ZoygLnXWGNdDb2skH4TOlf/EgSVlhdSA7YrepjLE4WDcJF5n8eEyWuAot
xHa3+GKeUvL8m+yoyFJd6We+j6I6pJz0c4k6yIgrGZouHdG2AKc4/eU6nYy4Dn55
vCG0J5DYC8npD4SiCWrGuQPGI0wmKVeDFCe9BzMdEvEXAcljOFWVYVq/OmlaLx/p
FcXmyRG9FgvE5q3PbYvpfgDSezO2ytBIphDmIfFb1/27q48PvHJXMU8cmW/tiX3t
R4h8mE9+p3DKJkLmky26arHYzZ4pKCE/MGc2FB76m88ovmRz1Sjp067lp0VSx1nP
a0K7B3UqH3Ia0yeLjFmaDES3jZZoylNtoEtpwcvmO/gYSgwlaOGoGVobxE67YIai
2Wq/a5N6ERp54NJHm4ubE+5V4ACrW/ox/qqwiX7DQcMKb1Z6W2bWPvd/dtUSbxy4
XtXqXcgtkIgHrudNn5/eGq+OOAzCTCOCGWEM/DalDe8rGvW7as4=
=QrCI
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.