comparison tests/test-frexp.c @ 9850:7f3ed6b093be

Guarantee a definition of NAN. * lib/math.in.h (NAN): Define if missing. * tests/test-math.c (main): Test it. * doc/posix-headers/math.texi (math.h): Document this. * lib/isnan.c (rpl_isnand): Use it. * tests/test-ceilf1.c (NaN): Delete, and use NAN instead. * tests/test-floorf1.c (NaN): Likewise. * tests/test-frexp.c (NaN): Likewise. * tests/test-isnand.c (NaN): Likewise. * tests/test-isnanf.c (NaN): Likewise. * tests/test-round1.c (NaN): Likewise. * tests/test-roundf1.c (NaN): Likewise. * tests/test-snprintf-posix.h (NaN): Likewise. * tests/test-sprintf-posix.h (NaN): Likewise. * tests/test-trunc1.c (NaN): Likewise. * tests/test-truncf1.c (NaN): Likewise. * tests/test-vasnprintf-posix.c (NaN): Likewise. * tests/test-vasprintf-posix.c (NaN): Likewise. * modules/isnand-nolibm (Depends-on): Add math. * modules/isnanf-nolibm (Depends-on): Likewise. * modules/isnanl (Depends-on): Likewise. * modules/isnanl-nolibm (Depends-on): Likewise. * modules/snprintf-posix-tests (Depends-on): Likewise. * modules/sprintf-posix-tests (Depends-on): Likewise. * modules/vsnprintf-posix-tests (Depends-on): Likewise. * modules/vsprintf-posix-tests (Depends-on): Likewise. * modules/vasnprintf-posix-tests (Depends-on): Likewise. * modules/vasprintf-posix-tests (Depends-on): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Mon, 31 Mar 2008 20:56:25 -0600
parents a113e473cc98
children baba3b346ab2
comparison
equal deleted inserted replaced
9849:ab48b8591214 9850:7f3ed6b093be
35 abort (); \ 35 abort (); \
36 } \ 36 } \
37 } \ 37 } \
38 while (0) 38 while (0)
39 39
40 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
41 #ifdef __DECC
42 static double
43 NaN ()
44 {
45 static double zero = 0.0;
46 return zero / zero;
47 }
48 #else
49 # define NaN() (0.0 / 0.0)
50 #endif
51
52 static double 40 static double
53 my_ldexp (double x, int d) 41 my_ldexp (double x, int d)
54 { 42 {
55 for (; d > 0; d--) 43 for (; d > 0; d--)
56 x *= 2.0; 44 x *= 2.0;
71 volatile double x; 59 volatile double x;
72 60
73 { /* NaN. */ 61 { /* NaN. */
74 int exp = -9999; 62 int exp = -9999;
75 double mantissa; 63 double mantissa;
76 x = NaN (); 64 x = NAN;
77 mantissa = frexp (x, &exp); 65 mantissa = frexp (x, &exp);
78 ASSERT (isnand (mantissa)); 66 ASSERT (isnand (mantissa));
79 } 67 }
80 68
81 { /* Positive infinity. */ 69 { /* Positive infinity. */