Mercurial > hg > octave-shane > gnulib-hg
changeset 8528:f25a6ce872b2
Correct bitwise comparison of 'long double' numbers.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 25 Mar 2007 01:06:39 +0000 |
parents | 7e5222add641 |
children | 5761935ad270 |
files | ChangeLog lib/isnan.c modules/isnan-nolibm modules/isnanl modules/isnanl-nolibm |
diffstat | 5 files changed, 23 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2007-03-24 Bruno Haible <bruno@clisp.org> + + * lib/float+.h: New file. + * lib/isnan.c: Include float+.h. + (SIZE): New macro. + (FUNC): Compare only SIZE bytes of the value. + * lib/vasnprintf.c: Include float+.h. + (VASNPRINTF): When comparing agains +0.0L or +0.0, compare only + SIZEOF_LDBL or SIZEOF_DBL bytes. + * modules/isnan-nolibm (Files): Add lib/float+.h. + * modules/isnanl-nolibm (Files): Add lib/float+.h. + * modules/isnanl (Files): Add lib/float+.h. + * modules/vasnprintf (Files): Add lib/float+.h. + 2007-03-24 Bruno Haible <bruno@clisp.org> * lib/vasnprintf.c [!HAVE_LONG_DOUBLE]: Include printf-frexp.h. Don't
--- a/lib/isnan.c +++ b/lib/isnan.c @@ -22,6 +22,8 @@ #include <float.h> #include <string.h> +#include "float+.h" + #ifdef USE_LONG_DOUBLE # define FUNC rpl_isnanl # define DOUBLE long double @@ -32,6 +34,7 @@ # define EXPBIT0_WORD LDBL_EXPBIT0_WORD # define EXPBIT0_BIT LDBL_EXPBIT0_BIT # endif +# define SIZE SIZEOF_LDBL # define L_(literal) literal##L #else # define FUNC rpl_isnan @@ -43,6 +46,7 @@ # define EXPBIT0_WORD DBL_EXPBIT0_WORD # define EXPBIT0_BIT DBL_EXPBIT0_BIT # endif +# define SIZE SIZEOF_DBL # define L_(literal) literal #endif @@ -79,8 +83,8 @@ if (((m.word[EXPBIT0_WORD] ^ nan.word[EXPBIT0_WORD]) & (EXP_MASK << EXPBIT0_BIT)) == 0) - return (memcmp (&m.value, &plus_inf, sizeof (DOUBLE)) != 0 - && memcmp (&m.value, &minus_inf, sizeof (DOUBLE)) != 0); + return (memcmp (&m.value, &plus_inf, SIZE) != 0 + && memcmp (&m.value, &minus_inf, SIZE) != 0); else return 0; }
--- a/modules/isnan-nolibm +++ b/modules/isnan-nolibm @@ -4,6 +4,7 @@ Files: lib/isnan.h lib/isnan.c +lib/float+.h m4/isnan.m4 Depends-on: