2004-12-06 Roland McGrath <roland@redhat.com>
[glibc.git] / math / bug-nextafter.c
blob2a967c75bf18f267944a2463c364c4e66ebb1700
1 #include <fenv.h>
2 #include <math.h>
3 #include <float.h>
4 #include <stdlib.h>
5 #include <stdio.h>
7 int
8 main (void)
10 int result = 0;
12 float i = INFINITY;
13 float m = FLT_MAX;
14 feclearexcept (FE_ALL_EXCEPT);
15 if (nextafterf (m, i) != i)
17 puts ("nextafterf+ failed");
18 ++result;
20 if (fetestexcept (FE_OVERFLOW) == 0)
22 puts ("nextafterf+ did not overflow");
23 ++result;
25 feclearexcept (FE_ALL_EXCEPT);
26 if (nextafterf (-m, -i) != -i)
28 puts ("nextafterf- failed");
29 ++result;
31 if (fetestexcept (FE_OVERFLOW) == 0)
33 puts ("nextafterf- did not overflow");
34 ++result;
37 double di = INFINITY;
38 double dm = DBL_MAX;
39 feclearexcept (FE_ALL_EXCEPT);
40 if (nextafter (dm, di) != di)
42 puts ("nextafter+ failed");
43 ++result;
45 if (fetestexcept (FE_OVERFLOW) == 0)
47 puts ("nextafter+ did not overflow");
48 ++result;
50 feclearexcept (FE_ALL_EXCEPT);
51 if (nextafter (-dm, -di) != -di)
53 puts ("nextafter failed");
54 ++result;
56 if (fetestexcept (FE_OVERFLOW) == 0)
58 puts ("nextafter- did not overflow");
59 ++result;
62 return result;