Hurd: fix mode type for openat
[glibc.git] / math / bug-nextafter.c
blob1d21841ea663edf9b2c346a436bb5882132e0b73
1 #include <fenv.h>
2 #include <math.h>
3 #include <float.h>
4 #include <stdlib.h>
5 #include <stdio.h>
7 float zero = 0.0;
8 float inf = INFINITY;
10 int
11 main (void)
13 int result = 0;
15 float i = INFINITY;
16 float m = FLT_MAX;
17 feclearexcept (FE_ALL_EXCEPT);
18 if (nextafterf (m, i) != i)
20 puts ("nextafterf+ failed");
21 ++result;
23 if (fetestexcept (FE_OVERFLOW) == 0)
25 puts ("nextafterf+ did not overflow");
26 ++result;
28 feclearexcept (FE_ALL_EXCEPT);
29 if (nextafterf (-m, -i) != -i)
31 puts ("nextafterf- failed");
32 ++result;
34 if (fetestexcept (FE_OVERFLOW) == 0)
36 puts ("nextafterf- did not overflow");
37 ++result;
40 i = 0;
41 m = FLT_MIN;
42 feclearexcept (FE_ALL_EXCEPT);
43 i = nextafterf (m, i);
44 if (i < 0 || i >= FLT_MIN)
46 puts ("nextafterf+ failed");
47 ++result;
49 if (fetestexcept (FE_UNDERFLOW) == 0)
51 puts ("nextafterf+ did not underflow");
52 ++result;
54 i = 0;
55 feclearexcept (FE_ALL_EXCEPT);
56 i = nextafterf (-m, -i);
57 if (i > 0 || i <= -FLT_MIN)
59 puts ("nextafterf- failed");
60 ++result;
62 if (fetestexcept (FE_UNDERFLOW) == 0)
64 puts ("nextafterf- did not underflow");
65 ++result;
67 i = -INFINITY;
68 feclearexcept (FE_ALL_EXCEPT);
69 m = nextafterf (zero, inf);
70 if (m < 0.0 || m >= FLT_MIN)
72 puts ("nextafterf+ failed");
73 ++result;
75 if (fetestexcept (FE_UNDERFLOW) == 0)
77 puts ("nextafterf+ did not underflow");
78 ++result;
80 feclearexcept (FE_ALL_EXCEPT);
81 if (nextafterf (m, i) != 0.0)
83 puts ("nextafterf+ failed");
84 ++result;
86 if (fetestexcept (FE_UNDERFLOW) == 0)
88 puts ("nextafterf+ did not underflow");
89 ++result;
91 feclearexcept (FE_ALL_EXCEPT);
92 m = nextafterf (copysignf (zero, -1.0), -inf);
93 if (m > 0.0 || m <= -FLT_MIN)
95 puts ("nextafterf- failed");
96 ++result;
98 if (fetestexcept (FE_UNDERFLOW) == 0)
100 puts ("nextafterf- did not underflow");
101 ++result;
103 feclearexcept (FE_ALL_EXCEPT);
104 if (nextafterf (m, -i) != 0.0)
106 puts ("nextafterf- failed");
107 ++result;
109 if (fetestexcept (FE_UNDERFLOW) == 0)
111 puts ("nextafterf- did not underflow");
112 ++result;
115 double di = INFINITY;
116 double dm = DBL_MAX;
117 feclearexcept (FE_ALL_EXCEPT);
118 if (nextafter (dm, di) != di)
120 puts ("nextafter+ failed");
121 ++result;
123 if (fetestexcept (FE_OVERFLOW) == 0)
125 puts ("nextafter+ did not overflow");
126 ++result;
128 feclearexcept (FE_ALL_EXCEPT);
129 if (nextafter (-dm, -di) != -di)
131 puts ("nextafter failed");
132 ++result;
134 if (fetestexcept (FE_OVERFLOW) == 0)
136 puts ("nextafter- did not overflow");
137 ++result;
140 di = 0;
141 dm = DBL_MIN;
142 feclearexcept (FE_ALL_EXCEPT);
143 di = nextafter (dm, di);
144 if (di < 0 || di >= DBL_MIN)
146 puts ("nextafter+ failed");
147 ++result;
149 if (fetestexcept (FE_UNDERFLOW) == 0)
151 puts ("nextafter+ did not underflow");
152 ++result;
154 di = 0;
155 feclearexcept (FE_ALL_EXCEPT);
156 di = nextafter (-dm, -di);
157 if (di > 0 || di <= -DBL_MIN)
159 puts ("nextafter- failed");
160 ++result;
162 if (fetestexcept (FE_UNDERFLOW) == 0)
164 puts ("nextafter- did not underflow");
165 ++result;
167 di = -INFINITY;
168 feclearexcept (FE_ALL_EXCEPT);
169 dm = nextafter (zero, inf);
170 if (dm < 0.0 || dm >= DBL_MIN)
172 puts ("nextafter+ failed");
173 ++result;
175 if (fetestexcept (FE_UNDERFLOW) == 0)
177 puts ("nextafter+ did not underflow");
178 ++result;
180 feclearexcept (FE_ALL_EXCEPT);
181 if (nextafter (dm, di) != 0.0)
183 puts ("nextafter+ failed");
184 ++result;
186 if (fetestexcept (FE_UNDERFLOW) == 0)
188 puts ("nextafter+ did not underflow");
189 ++result;
191 feclearexcept (FE_ALL_EXCEPT);
192 dm = nextafter (copysign (zero, -1.0), -inf);
193 if (dm > 0.0 || dm <= -DBL_MIN)
195 puts ("nextafter- failed");
196 ++result;
198 if (fetestexcept (FE_UNDERFLOW) == 0)
200 puts ("nextafter- did not underflow");
201 ++result;
203 feclearexcept (FE_ALL_EXCEPT);
204 if (nextafter (dm, -di) != 0.0)
206 puts ("nextafter- failed");
207 ++result;
209 if (fetestexcept (FE_UNDERFLOW) == 0)
211 puts ("nextafter- did not underflow");
212 ++result;
215 #ifndef NO_LONG_DOUBLE
216 long double li = INFINITY;
217 long double lm = LDBL_MAX;
218 feclearexcept (FE_ALL_EXCEPT);
219 if (nextafterl (lm, li) != li)
221 puts ("nextafterl+ failed");
222 ++result;
224 if (fetestexcept (FE_OVERFLOW) == 0)
226 puts ("nextafterl+ did not overflow");
227 ++result;
229 feclearexcept (FE_ALL_EXCEPT);
230 if (nextafterl (-lm, -li) != -li)
232 puts ("nextafterl failed");
233 ++result;
235 if (fetestexcept (FE_OVERFLOW) == 0)
237 puts ("nextafterl- did not overflow");
238 ++result;
241 li = 0;
242 lm = LDBL_MIN;
243 feclearexcept (FE_ALL_EXCEPT);
244 li = nextafterl (lm, li);
245 if (li < 0 || li >= LDBL_MIN)
247 puts ("nextafterl+ failed");
248 ++result;
250 if (fetestexcept (FE_UNDERFLOW) == 0)
252 puts ("nextafterl+ did not underflow");
253 ++result;
255 li = 0;
256 feclearexcept (FE_ALL_EXCEPT);
257 li = nextafterl (-lm, -li);
258 if (li > 0 || li <= -LDBL_MIN)
260 puts ("nextafterl- failed");
261 ++result;
263 if (fetestexcept (FE_UNDERFLOW) == 0)
265 puts ("nextafterl- did not underflow");
266 ++result;
268 li = -INFINITY;
269 feclearexcept (FE_ALL_EXCEPT);
270 lm = nextafterl (zero, inf);
271 if (lm < 0.0 || lm >= LDBL_MIN)
273 puts ("nextafterl+ failed");
274 ++result;
276 if (fetestexcept (FE_UNDERFLOW) == 0)
278 puts ("nextafterl+ did not underflow");
279 ++result;
281 feclearexcept (FE_ALL_EXCEPT);
282 if (nextafterl (lm, li) != 0.0)
284 puts ("nextafterl+ failed");
285 ++result;
287 if (fetestexcept (FE_UNDERFLOW) == 0)
289 puts ("nextafterl+ did not underflow");
290 ++result;
292 feclearexcept (FE_ALL_EXCEPT);
293 lm = nextafterl (copysign (zero, -1.0), -inf);
294 if (lm > 0.0 || lm <= -LDBL_MIN)
296 puts ("nextafterl- failed");
297 ++result;
299 if (fetestexcept (FE_UNDERFLOW) == 0)
301 puts ("nextafterl- did not underflow");
302 ++result;
304 feclearexcept (FE_ALL_EXCEPT);
305 if (nextafterl (lm, -li) != 0.0)
307 puts ("nextafterl- failed");
308 ++result;
310 if (fetestexcept (FE_UNDERFLOW) == 0)
312 puts ("nextafterl- did not underflow");
313 ++result;
315 #endif
317 return result;