aboutsummaryrefslogtreecommitdiff
path: root/stdio-common/printf_fp.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-08-23 11:57:52 -0700
committerUlrich Drepper <drepper@redhat.com>2009-08-23 11:57:52 -0700
commit003c9895a89e71767ad64bafac1ca99622be2eb7 (patch)
tree86902c3ea811ee8c4b8507a026f5563306340357 /stdio-common/printf_fp.c
parent659a63fb7ba0b2c9bc45034283a302afe56a6ebe (diff)
downloadglibc-003c9895a89e71767ad64bafac1ca99622be2eb7.zip
glibc-003c9895a89e71767ad64bafac1ca99622be2eb7.tar.gz
glibc-003c9895a89e71767ad64bafac1ca99622be2eb7.tar.bz2
Print sign of NaN values.
Diffstat (limited to 'stdio-common/printf_fp.c')
-rw-r--r--stdio-common/printf_fp.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 43c43c2..cd3ada6 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -28,6 +28,7 @@
#include <float.h>
#include <gmp-mparam.h>
#include <gmp.h>
+#include <ieee754.h>
#include <stdlib/gmp-impl.h>
#include <stdlib/longlong.h>
#include <stdlib/fpioconst.h>
@@ -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";