From 555acda4637f118f03f674071b8199eac1e9e0f2 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 25 Mar 2007 01:11:49 +0000 Subject: [PATCH] Correct bitwise comparison of 'long double' numbers. --- lib/vasnprintf.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index bc80b444a..00419aaaa 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -51,6 +51,7 @@ #include "xsize.h" #if NEED_PRINTF_DIRECTIVE_A && !defined IN_LIBINTL +# include "float+.h" # include "isnan.h" # include "printf-frexp.h" # if HAVE_LONG_DOUBLE @@ -424,10 +425,8 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar { /* Distinguish 0.0L and -0.0L. */ static long double plus_zero = 0.0L; - long double arg_mem; - memset (&arg_mem, 0, sizeof (long double)); - arg_mem = arg; - if (memcmp (&plus_zero, &arg_mem, sizeof (long double)) != 0) + long double arg_mem = arg; + if (memcmp (&plus_zero, &arg_mem, SIZEOF_LDBL) != 0) { sign = -1; arg = -arg; @@ -574,10 +573,8 @@ VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list ar { /* Distinguish 0.0 and -0.0. */ static double plus_zero = 0.0; - double arg_mem; - memset (&arg_mem, 0, sizeof (double)); - arg_mem = arg; - if (memcmp (&plus_zero, &arg_mem, sizeof (double)) != 0) + double arg_mem = arg; + if (memcmp (&plus_zero, &arg_mem, SIZEOF_DBL) != 0) { sign = -1; arg = -arg; -- 2.11.0