* Re: newlib Digest of: get.16090
[not found] <1531492934.123366.ezmlm@sourceware.org>
@ 2018-07-13 15:32 ` Thomas Preudhomme
2018-07-14 15:16 ` [PATCH] Print sign of NaN values to nano-vfprintf Thomas Preudhomme
1 sibling, 0 replies; 8+ messages in thread
From: Thomas Preudhomme @ 2018-07-13 15:32 UTC (permalink / raw)
To: newlib, Corinna Vinschen
> From: Corinna Vinschen <vinschen@redhat.com>
> To: newlib@sourceware.org, Bin Cheng <bin.cheng@arm.com>
> Cc: Kumar Gala <kumar.gala@linaro.org>
> Bcc:
> Date: Fri, 13 Jul 2018 13:37:43 +0200
> Subject: Re: [PATCH] Print sign of NaN values to nano-vfprintf.
> On Jul 12 13:13, Kumar Gala wrote:
> > Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
> > ---
> > newlib/libc/stdio/nano-vfprintf_float.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > 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";
> > else
> > --
> > 2.14.4
>
> Any comment from the nano-printf guys?
LGTM.
>
> Thanks,
> Corinna
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat
Best regards,
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Print sign of NaN values to nano-vfprintf.
[not found] <1531492934.123366.ezmlm@sourceware.org>
2018-07-13 15:32 ` newlib Digest of: get.16090 Thomas Preudhomme
@ 2018-07-14 15:16 ` Thomas Preudhomme
1 sibling, 0 replies; 8+ messages in thread
From: Thomas Preudhomme @ 2018-07-14 15:16 UTC (permalink / raw)
To: newlib, Corinna Vinschen
[resending with the right subject]
> From: Corinna Vinschen <vinschen@redhat.com>
> To: newlib@sourceware.org, Bin Cheng <bin.cheng@arm.com>
> Cc: Kumar Gala <kumar.gala@linaro.org>
> Bcc:
> Date: Fri, 13 Jul 2018 13:37:43 +0200
> Subject: Re: [PATCH] Print sign of NaN values to nano-vfprintf.
> On Jul 12 13:13, Kumar Gala wrote:
> > Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
> > ---
> > newlib/libc/stdio/nano-vfprintf_float.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > 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";
> > else
> > --
> > 2.14.4
>
> Any comment from the nano-printf guys?
LGTM.
>
> Thanks,
> Corinna
>
> --
> Corinna Vinschen
> Cygwin Maintainer
> Red Hat
Best regards,
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Print sign of NaN values to nano-vfprintf.
2018-12-11 22:08 jon
2018-12-12 12:24 ` Richard Earnshaw (lists)
@ 2018-12-13 12:56 ` Corinna Vinschen
1 sibling, 0 replies; 8+ messages in thread
From: Corinna Vinschen @ 2018-12-13 12:56 UTC (permalink / raw)
To: jon; +Cc: newlib
[-- Attachment #1: Type: text/plain, Size: 932 bytes --]
On Dec 11 21:13, jon@beniston.com 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Print sign of NaN values to nano-vfprintf.
2018-12-11 22:08 jon
@ 2018-12-12 12:24 ` Richard Earnshaw (lists)
2018-12-13 12:56 ` Corinna Vinschen
1 sibling, 0 replies; 8+ messages in thread
From: Richard Earnshaw (lists) @ 2018-12-12 12:24 UTC (permalink / raw)
To: jon, newlib
On 11/12/2018 21:13, jon@beniston.com 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.
>
That will work better for -0 as well. LGTM
R.
> Cheers,
> Jon
>
>
> 0001-nano-vfprintf_float.c-Fix-check-if-negative-for-nans.patch
>
> From 49593628a465af4e8409ed2aac142b9ed347156e Mon Sep 17 00:00:00 2001
> From: Jon Beniston <jon@beniston.com>
> Date: Tue, 11 Dec 2018 21:03:03 +0000
> Subject: [PATCH] nano-vfprintf_float.c: Fix check if negative for nans.
>
> ---
> newlib/libc/stdio/nano-vfprintf_float.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/newlib/libc/stdio/nano-vfprintf_float.c b/newlib/libc/stdio/nano-vfprintf_float.c
> index 071a09edc..524f67a31 100644
> --- a/newlib/libc/stdio/nano-vfprintf_float.c
> +++ b/newlib/libc/stdio/nano-vfprintf_float.c
> @@ -39,6 +39,7 @@
> #include <string.h>
> #include <limits.h>
> #include <stdint.h>
> +#include <math.h>
> #include <wchar.h>
> #include <sys/lock.h>
> #include <stdarg.h>
> @@ -213,7 +214,7 @@ _printf_float (struct _reent *data,
> }
> if (isnan (_fpvalue))
> {
> - if (_fpvalue < 0)
> + if (signbit (_fpvalue))
> pdata->l_buf[0] = '-';
> if (code <= 'G') /* 'A', 'E', 'F', or 'G'. */
> cp = "NAN";
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Print sign of NaN values to nano-vfprintf.
@ 2018-12-11 22:08 jon
2018-12-12 12:24 ` Richard Earnshaw (lists)
2018-12-13 12:56 ` Corinna Vinschen
0 siblings, 2 replies; 8+ messages in thread
From: jon @ 2018-12-11 22:08 UTC (permalink / raw)
To: newlib
[-- Attachment #1: Type: text/plain, Size: 745 bytes --]
> 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.
Cheers,
Jon
[-- Attachment #2: 0001-nano-vfprintf_float.c-Fix-check-if-negative-for-nans.patch --]
[-- Type: application/octet-stream, Size: 997 bytes --]
From 49593628a465af4e8409ed2aac142b9ed347156e Mon Sep 17 00:00:00 2001
From: Jon Beniston <jon@beniston.com>
Date: Tue, 11 Dec 2018 21:03:03 +0000
Subject: [PATCH] nano-vfprintf_float.c: Fix check if negative for nans.
---
newlib/libc/stdio/nano-vfprintf_float.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/newlib/libc/stdio/nano-vfprintf_float.c b/newlib/libc/stdio/nano-vfprintf_float.c
index 071a09edc..524f67a31 100644
--- a/newlib/libc/stdio/nano-vfprintf_float.c
+++ b/newlib/libc/stdio/nano-vfprintf_float.c
@@ -39,6 +39,7 @@
#include <string.h>
#include <limits.h>
#include <stdint.h>
+#include <math.h>
#include <wchar.h>
#include <sys/lock.h>
#include <stdarg.h>
@@ -213,7 +214,7 @@ _printf_float (struct _reent *data,
}
if (isnan (_fpvalue))
{
- if (_fpvalue < 0)
+ if (signbit (_fpvalue))
pdata->l_buf[0] = '-';
if (code <= 'G') /* 'A', 'E', 'F', or 'G'. */
cp = "NAN";
--
2.17.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Print sign of NaN values to nano-vfprintf.
2018-07-13 10:15 Kumar Gala
2018-07-13 12:14 ` Corinna Vinschen
@ 2018-07-20 2:00 ` Corinna Vinschen
1 sibling, 0 replies; 8+ messages in thread
From: Corinna Vinschen @ 2018-07-20 2:00 UTC (permalink / raw)
To: newlib
[-- Attachment #1: Type: text/plain, Size: 776 bytes --]
On Jul 12 13:13, Kumar Gala wrote:
> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
> ---
> newlib/libc/stdio/nano-vfprintf_float.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> 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";
> else
> --
> 2.14.4
Pushed.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Print sign of NaN values to nano-vfprintf.
2018-07-13 10:15 Kumar Gala
@ 2018-07-13 12:14 ` Corinna Vinschen
2018-07-20 2:00 ` Corinna Vinschen
1 sibling, 0 replies; 8+ messages in thread
From: Corinna Vinschen @ 2018-07-13 12:14 UTC (permalink / raw)
To: newlib, Bin Cheng; +Cc: Kumar Gala
[-- Attachment #1: Type: text/plain, Size: 805 bytes --]
On Jul 12 13:13, Kumar Gala wrote:
> Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
> ---
> newlib/libc/stdio/nano-vfprintf_float.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> 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";
> else
> --
> 2.14.4
Any comment from the nano-printf guys?
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] Print sign of NaN values to nano-vfprintf.
@ 2018-07-13 10:15 Kumar Gala
2018-07-13 12:14 ` Corinna Vinschen
2018-07-20 2:00 ` Corinna Vinschen
0 siblings, 2 replies; 8+ messages in thread
From: Kumar Gala @ 2018-07-13 10:15 UTC (permalink / raw)
To: newlib; +Cc: Kumar Gala
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
---
newlib/libc/stdio/nano-vfprintf_float.c | 2 ++
1 file changed, 2 insertions(+)
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";
else
--
2.14.4
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-12-13 12:16 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1531492934.123366.ezmlm@sourceware.org>
2018-07-13 15:32 ` newlib Digest of: get.16090 Thomas Preudhomme
2018-07-14 15:16 ` [PATCH] Print sign of NaN values to nano-vfprintf Thomas Preudhomme
2018-12-11 22:08 jon
2018-12-12 12:24 ` Richard Earnshaw (lists)
2018-12-13 12:56 ` Corinna Vinschen
-- strict thread matches above, loose matches on Subject: below --
2018-07-13 10:15 Kumar Gala
2018-07-13 12:14 ` Corinna Vinschen
2018-07-20 2:00 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).