* [PATCH] Print sign of NaN values
@ 2017-06-03 13:54 Kito Cheng
2017-06-05 16:46 ` Craig Howland
0 siblings, 1 reply; 4+ messages in thread
From: Kito Cheng @ 2017-06-03 13:54 UTC (permalink / raw)
To: newlib
[-- Attachment #1: Type: text/plain, Size: 167 bytes --]
This patch let -NaN can print the right sign like glibc do[1] :)
Ref:
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=003c9895a89e71767ad64bafac1ca99622be2eb7
[-- Attachment #2: 0001-Print-sign-of-NaN-values.patch --]
[-- Type: text/x-patch, Size: 1521 bytes --]
From 30d2773c0e60a30c8b367f9c021d6e1fdf2a3abb Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng@gmail.com>
Date: Sat, 3 Jun 2017 21:41:29 +0800
Subject: [PATCH] Print sign of NaN values.
---
newlib/libc/stdio/vfprintf.c | 4 ++++
newlib/libc/stdio/vfwprintf.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index ed92bb2..3585423 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -1245,6 +1245,8 @@ reswitch: switch (ch) {
break;
}
if (isnan (_fpvalue)) {
+ if (signbit (_fpvalue))
+ sign = '-';
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */
cp = "NAN";
else
@@ -1276,6 +1278,8 @@ reswitch: switch (ch) {
break;
}
if (expt == 1) {
+ if (signbit (_fpvalue))
+ sign = '-';
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */
cp = "NAN";
else
diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c
index f0179a0..106904c 100644
--- a/newlib/libc/stdio/vfwprintf.c
+++ b/newlib/libc/stdio/vfwprintf.c
@@ -970,6 +970,8 @@ reswitch: switch (ch) {
break;
}
if (isnan (_fpvalue)) {
+ if (signbit (_fpvalue))
+ sign = '-';
if (ch <= L'G') /* 'A', 'E', 'F', or 'G' */
cp = L"NAN";
else
@@ -1001,6 +1003,8 @@ reswitch: switch (ch) {
break;
}
if (expt == 1) {
+ if (signbit (_fpvalue))
+ sign = '-';
if (ch <= L'G') /* 'A', 'E', 'F', or 'G' */
cp = L"NAN";
else
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Print sign of NaN values
2017-06-03 13:54 [PATCH] Print sign of NaN values Kito Cheng
@ 2017-06-05 16:46 ` Craig Howland
2017-06-07 6:56 ` Kito Cheng
0 siblings, 1 reply; 4+ messages in thread
From: Craig Howland @ 2017-06-05 16:46 UTC (permalink / raw)
To: newlib
On 06/03/2017 09:54 AM, Kito Cheng wrote:
> This patch let -NaN can print the right sign like glibc do[1] :)
>
> Ref:
> [1] https://sourceware.org/git/?p=glibc.git;a=commit;h=003c9895a89e71767ad64bafac1ca99622be2eb7
For vfwprintf.c, the two assignments to sign ought to be "sign = L'-';" (missing
the L).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Print sign of NaN values
2017-06-05 16:46 ` Craig Howland
@ 2017-06-07 6:56 ` Kito Cheng
2017-06-07 9:58 ` Corinna Vinschen
0 siblings, 1 reply; 4+ messages in thread
From: Kito Cheng @ 2017-06-07 6:56 UTC (permalink / raw)
To: Craig Howland; +Cc: newlib
[-- Attachment #1: Type: text/plain, Size: 466 bytes --]
Hi Craig:
Thanks your review :)
here is updated patch.
On Tue, Jun 6, 2017 at 12:45 AM, Craig Howland
<howland@lgsinnovations.com> wrote:
> On 06/03/2017 09:54 AM, Kito Cheng wrote:
>>
>> This patch let -NaN can print the right sign like glibc do[1] :)
>>
>> Ref:
>> [1]
>> https://sourceware.org/git/?p=glibc.git;a=commit;h=003c9895a89e71767ad64bafac1ca99622be2eb7
>
> For vfwprintf.c, the two assignments to sign ought to be "sign = L'-';"
> (missing the L).
>
[-- Attachment #2: 0001-Print-sign-of-NaN-values.patch --]
[-- Type: text/x-patch, Size: 1523 bytes --]
From 93a618861e85a404a9ad7e4933dab566a55e1d5f Mon Sep 17 00:00:00 2001
From: Kito Cheng <kito.cheng@gmail.com>
Date: Sat, 3 Jun 2017 21:41:29 +0800
Subject: [PATCH] Print sign of NaN values.
---
newlib/libc/stdio/vfprintf.c | 4 ++++
newlib/libc/stdio/vfwprintf.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
index ed92bb2..3585423 100644
--- a/newlib/libc/stdio/vfprintf.c
+++ b/newlib/libc/stdio/vfprintf.c
@@ -1245,6 +1245,8 @@ reswitch: switch (ch) {
break;
}
if (isnan (_fpvalue)) {
+ if (signbit (_fpvalue))
+ sign = '-';
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */
cp = "NAN";
else
@@ -1276,6 +1278,8 @@ reswitch: switch (ch) {
break;
}
if (expt == 1) {
+ if (signbit (_fpvalue))
+ sign = '-';
if (ch <= 'G') /* 'A', 'E', 'F', or 'G' */
cp = "NAN";
else
diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c
index f0179a0..4786ed6 100644
--- a/newlib/libc/stdio/vfwprintf.c
+++ b/newlib/libc/stdio/vfwprintf.c
@@ -970,6 +970,8 @@ reswitch: switch (ch) {
break;
}
if (isnan (_fpvalue)) {
+ if (signbit (_fpvalue))
+ sign = L'-';
if (ch <= L'G') /* 'A', 'E', 'F', or 'G' */
cp = L"NAN";
else
@@ -1001,6 +1003,8 @@ reswitch: switch (ch) {
break;
}
if (expt == 1) {
+ if (signbit (_fpvalue))
+ sign = L'-';
if (ch <= L'G') /* 'A', 'E', 'F', or 'G' */
cp = L"NAN";
else
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Print sign of NaN values
2017-06-07 6:56 ` Kito Cheng
@ 2017-06-07 9:58 ` Corinna Vinschen
0 siblings, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2017-06-07 9:58 UTC (permalink / raw)
To: newlib
[-- Attachment #1: Type: text/plain, Size: 645 bytes --]
On Jun 7 14:55, Kito Cheng wrote:
> Hi Craig:
>
> Thanks your review :)
>
> here is updated patch.
>
> On Tue, Jun 6, 2017 at 12:45 AM, Craig Howland
> <howland@lgsinnovations.com> wrote:
> > On 06/03/2017 09:54 AM, Kito Cheng wrote:
> >>
> >> This patch let -NaN can print the right sign like glibc do[1] :)
> >>
> >> Ref:
> >> [1]
> >> https://sourceware.org/git/?p=glibc.git;a=commit;h=003c9895a89e71767ad64bafac1ca99622be2eb7
> >
> > For vfwprintf.c, the two assignments to sign ought to be "sign = L'-';"
> > (missing the L).
> >
Pushed.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-07 9:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-03 13:54 [PATCH] Print sign of NaN values Kito Cheng
2017-06-05 16:46 ` Craig Howland
2017-06-07 6:56 ` Kito Cheng
2017-06-07 9:58 ` 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).