Update.
[glibc.git] / math / bug-nexttoward.c
blobe306a129c2cac1567ec1bcb4a52dda0ad6eec3a1
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 long double tl = (long double) FLT_MAX + 0x1.0p128L;
13 float fi = INFINITY;
14 float m = FLT_MAX;
15 feclearexcept (FE_ALL_EXCEPT);
16 if (nexttowardf (m, tl) != fi)
18 puts ("nexttowardf+ failed");
19 ++result;
21 if (fetestexcept (FE_OVERFLOW) == 0)
23 puts ("nexttowardf+ did not overflow");
24 ++result;
26 feclearexcept (FE_ALL_EXCEPT);
27 if (nexttowardf (-m, -tl) != -fi)
29 puts ("nexttowardf- failed");
30 ++result;
32 if (fetestexcept (FE_OVERFLOW) == 0)
34 puts ("nexttowardf- did not overflow");
35 ++result;
38 tl = (long double) DBL_MAX + 1.0e305L;
39 double di = INFINITY;
40 double dm = DBL_MAX;
41 feclearexcept (FE_ALL_EXCEPT);
42 if (nexttoward (dm, tl) != di)
44 puts ("nexttoward+ failed");
45 ++result;
47 if (fetestexcept (FE_OVERFLOW) == 0)
49 puts ("nexttoward+ did not overflow");
50 ++result;
52 feclearexcept (FE_ALL_EXCEPT);
53 if (nexttoward (-dm, -tl) != -di)
55 puts ("nexttoward- failed");
56 ++result;
58 if (fetestexcept (FE_OVERFLOW) == 0)
60 puts ("nexttoward- did not overflow");
61 ++result;
64 return result;