Correct bitwise comparison of 'long double' numbers.
authorBruno Haible <bruno@clisp.org>
Sun, 25 Mar 2007 01:11:49 +0000 (01:11 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 25 Mar 2007 01:11:49 +0000 (01:11 +0000)
lib/vasnprintf.c

index bc80b44..00419aa 100644 (file)
@@ -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;