7 #if !defined(FE_OVERFLOW) && !defined(FE_UNDERFLOW)
8 /* If there's no support for the exceptions this test is checking,
9 then just return success and allow the test to be compiled. */
10 # define fetestexcept(e) 1
23 feclearexcept (FE_ALL_EXCEPT
);
24 if (nextafterf (m
, i
) != i
)
26 puts ("nextafterf+ failed");
29 if (fetestexcept (FE_OVERFLOW
) == 0)
31 puts ("nextafterf+ did not overflow");
34 feclearexcept (FE_ALL_EXCEPT
);
35 if (nextafterf (-m
, -i
) != -i
)
37 puts ("nextafterf- failed");
40 if (fetestexcept (FE_OVERFLOW
) == 0)
42 puts ("nextafterf- did not overflow");
48 feclearexcept (FE_ALL_EXCEPT
);
49 i
= nextafterf (m
, i
);
50 if (i
< 0 || i
>= FLT_MIN
)
52 puts ("nextafterf+ failed");
55 if (fetestexcept (FE_UNDERFLOW
) == 0)
57 puts ("nextafterf+ did not underflow");
61 feclearexcept (FE_ALL_EXCEPT
);
62 i
= nextafterf (-m
, -i
);
63 if (i
> 0 || i
<= -FLT_MIN
)
65 puts ("nextafterf- failed");
68 if (fetestexcept (FE_UNDERFLOW
) == 0)
70 puts ("nextafterf- did not underflow");
74 feclearexcept (FE_ALL_EXCEPT
);
75 m
= nextafterf (zero
, inf
);
76 if (m
< 0.0 || m
>= FLT_MIN
)
78 puts ("nextafterf+ failed");
81 if (fetestexcept (FE_UNDERFLOW
) == 0)
83 puts ("nextafterf+ did not underflow");
86 feclearexcept (FE_ALL_EXCEPT
);
87 if (nextafterf (m
, i
) != 0.0)
89 puts ("nextafterf+ failed");
92 if (fetestexcept (FE_UNDERFLOW
) == 0)
94 puts ("nextafterf+ did not underflow");
97 feclearexcept (FE_ALL_EXCEPT
);
98 m
= nextafterf (copysignf (zero
, -1.0), -inf
);
99 if (m
> 0.0 || m
<= -FLT_MIN
)
101 puts ("nextafterf- failed");
104 if (fetestexcept (FE_UNDERFLOW
) == 0)
106 puts ("nextafterf- did not underflow");
109 feclearexcept (FE_ALL_EXCEPT
);
110 if (nextafterf (m
, -i
) != 0.0)
112 puts ("nextafterf- failed");
115 if (fetestexcept (FE_UNDERFLOW
) == 0)
117 puts ("nextafterf- did not underflow");
121 double di
= INFINITY
;
123 feclearexcept (FE_ALL_EXCEPT
);
124 if (nextafter (dm
, di
) != di
)
126 puts ("nextafter+ failed");
129 if (fetestexcept (FE_OVERFLOW
) == 0)
131 puts ("nextafter+ did not overflow");
134 feclearexcept (FE_ALL_EXCEPT
);
135 if (nextafter (-dm
, -di
) != -di
)
137 puts ("nextafter failed");
140 if (fetestexcept (FE_OVERFLOW
) == 0)
142 puts ("nextafter- did not overflow");
148 feclearexcept (FE_ALL_EXCEPT
);
149 di
= nextafter (dm
, di
);
150 if (di
< 0 || di
>= DBL_MIN
)
152 puts ("nextafter+ failed");
155 if (fetestexcept (FE_UNDERFLOW
) == 0)
157 puts ("nextafter+ did not underflow");
161 feclearexcept (FE_ALL_EXCEPT
);
162 di
= nextafter (-dm
, -di
);
163 if (di
> 0 || di
<= -DBL_MIN
)
165 puts ("nextafter- failed");
168 if (fetestexcept (FE_UNDERFLOW
) == 0)
170 puts ("nextafter- did not underflow");
174 feclearexcept (FE_ALL_EXCEPT
);
175 dm
= nextafter (zero
, inf
);
176 if (dm
< 0.0 || dm
>= DBL_MIN
)
178 puts ("nextafter+ failed");
181 if (fetestexcept (FE_UNDERFLOW
) == 0)
183 puts ("nextafter+ did not underflow");
186 feclearexcept (FE_ALL_EXCEPT
);
187 if (nextafter (dm
, di
) != 0.0)
189 puts ("nextafter+ failed");
192 if (fetestexcept (FE_UNDERFLOW
) == 0)
194 puts ("nextafter+ did not underflow");
197 feclearexcept (FE_ALL_EXCEPT
);
198 dm
= nextafter (copysign (zero
, -1.0), -inf
);
199 if (dm
> 0.0 || dm
<= -DBL_MIN
)
201 puts ("nextafter- failed");
204 if (fetestexcept (FE_UNDERFLOW
) == 0)
206 puts ("nextafter- did not underflow");
209 feclearexcept (FE_ALL_EXCEPT
);
210 if (nextafter (dm
, -di
) != 0.0)
212 puts ("nextafter- failed");
215 if (fetestexcept (FE_UNDERFLOW
) == 0)
217 puts ("nextafter- did not underflow");
221 #ifndef NO_LONG_DOUBLE
222 long double li
= INFINITY
;
223 long double lm
= LDBL_MAX
;
224 feclearexcept (FE_ALL_EXCEPT
);
225 if (nextafterl (lm
, li
) != li
)
227 puts ("nextafterl+ failed");
230 if (fetestexcept (FE_OVERFLOW
) == 0)
232 puts ("nextafterl+ did not overflow");
235 feclearexcept (FE_ALL_EXCEPT
);
236 if (nextafterl (-lm
, -li
) != -li
)
238 puts ("nextafterl failed");
241 if (fetestexcept (FE_OVERFLOW
) == 0)
243 puts ("nextafterl- did not overflow");
249 feclearexcept (FE_ALL_EXCEPT
);
250 li
= nextafterl (lm
, li
);
251 if (li
< 0 || li
>= LDBL_MIN
)
253 puts ("nextafterl+ failed");
256 if (fetestexcept (FE_UNDERFLOW
) == 0)
258 puts ("nextafterl+ did not underflow");
262 feclearexcept (FE_ALL_EXCEPT
);
263 li
= nextafterl (-lm
, -li
);
264 if (li
> 0 || li
<= -LDBL_MIN
)
266 puts ("nextafterl- failed");
269 if (fetestexcept (FE_UNDERFLOW
) == 0)
271 puts ("nextafterl- did not underflow");
275 feclearexcept (FE_ALL_EXCEPT
);
276 lm
= nextafterl (zero
, inf
);
277 if (lm
< 0.0 || lm
>= LDBL_MIN
)
279 puts ("nextafterl+ failed");
282 if (fetestexcept (FE_UNDERFLOW
) == 0)
284 puts ("nextafterl+ did not underflow");
287 feclearexcept (FE_ALL_EXCEPT
);
288 if (nextafterl (lm
, li
) != 0.0)
290 puts ("nextafterl+ failed");
293 if (fetestexcept (FE_UNDERFLOW
) == 0)
295 puts ("nextafterl+ did not underflow");
298 feclearexcept (FE_ALL_EXCEPT
);
299 lm
= nextafterl (copysign (zero
, -1.0), -inf
);
300 if (lm
> 0.0 || lm
<= -LDBL_MIN
)
302 puts ("nextafterl- failed");
305 if (fetestexcept (FE_UNDERFLOW
) == 0)
307 puts ("nextafterl- did not underflow");
310 feclearexcept (FE_ALL_EXCEPT
);
311 if (nextafterl (lm
, -li
) != 0.0)
313 puts ("nextafterl- failed");
316 if (fetestexcept (FE_UNDERFLOW
) == 0)
318 puts ("nextafterl- did not underflow");