From 003c9895a89e71767ad64bafac1ca99622be2eb7 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 23 Aug 2009 11:57:52 -0700 Subject: Print sign of NaN values. --- stdio-common/printf_fp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'stdio-common/printf_fp.c') diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c index 43c43c2039..cd3ada6441 100644 --- a/stdio-common/printf_fp.c +++ b/stdio-common/printf_fp.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -335,6 +336,8 @@ ___printf_fp (FILE *fp, /* Check for special values: not a number or infinity. */ if (__isnanl (fpnum.ldbl)) { + union ieee854_long_double u = { .d = fpnum.ldbl }; + is_neg = u.ieee.negative != 0; if (isupper (info->spec)) { special = "NAN"; @@ -345,10 +348,10 @@ ___printf_fp (FILE *fp, special = "nan"; wspecial = L"nan"; } - is_neg = 0; } else if (__isinfl (fpnum.ldbl)) { + is_neg = fpnum.ldbl < 0; if (isupper (info->spec)) { special = "INF"; @@ -359,7 +362,6 @@ ___printf_fp (FILE *fp, special = "inf"; wspecial = L"inf"; } - is_neg = fpnum.ldbl < 0; } else { @@ -379,7 +381,8 @@ ___printf_fp (FILE *fp, /* Check for special values: not a number or infinity. */ if (__isnan (fpnum.dbl)) { - is_neg = 0; + union ieee754_double u = { .d = fpnum.dbl }; + is_neg = u.ieee.negative != 0; if (isupper (info->spec)) { special = "NAN"; -- cgit v1.2.3