15 long double tl
= (long double) FLT_MAX
+ 0x1.0p128L
;
18 feclearexcept (FE_ALL_EXCEPT
);
19 if (nexttowardf (m
, tl
) != fi
)
21 puts ("nexttowardf+ failed");
24 if (fetestexcept (FE_OVERFLOW
) == 0)
26 puts ("nexttowardf+ did not overflow");
29 feclearexcept (FE_ALL_EXCEPT
);
30 if (nexttowardf (-m
, -tl
) != -fi
)
32 puts ("nexttowardf- failed");
35 if (fetestexcept (FE_OVERFLOW
) == 0)
37 puts ("nexttowardf- did not overflow");
43 feclearexcept (FE_ALL_EXCEPT
);
44 fi
= nexttowardf (m
, fi
);
45 if (fi
< 0 || fi
>= FLT_MIN
)
47 puts ("nexttowardf+ failed");
50 if (fetestexcept (FE_UNDERFLOW
) == 0)
52 puts ("nexttowardf+ did not underflow");
56 feclearexcept (FE_ALL_EXCEPT
);
57 fi
= nexttowardf (-m
, -fi
);
58 if (fi
> 0 || fi
<= -FLT_MIN
)
60 puts ("nexttowardf- failed");
63 if (fetestexcept (FE_UNDERFLOW
) == 0)
65 puts ("nexttowardf- did not underflow");
69 feclearexcept (FE_ALL_EXCEPT
);
70 m
= nexttowardf (zero
, inf
);
71 if (m
< 0.0 || m
>= FLT_MIN
)
73 puts ("nexttowardf+ failed");
76 if (fetestexcept (FE_UNDERFLOW
) == 0)
78 puts ("nexttowardf+ did not underflow");
81 feclearexcept (FE_ALL_EXCEPT
);
82 if (nexttowardf (m
, fi
) != 0.0)
84 puts ("nexttowardf+ failed");
87 if (fetestexcept (FE_UNDERFLOW
) == 0)
89 puts ("nexttowardf+ did not underflow");
92 feclearexcept (FE_ALL_EXCEPT
);
93 m
= nexttowardf (copysignf (zero
, -1.0), -inf
);
94 if (m
> 0.0 || m
<= -FLT_MIN
)
96 puts ("nexttowardf- failed");
99 if (fetestexcept (FE_UNDERFLOW
) == 0)
101 puts ("nexttowardf- did not underflow");
104 feclearexcept (FE_ALL_EXCEPT
);
105 if (nexttowardf (m
, -fi
) != 0.0)
107 puts ("nexttowardf- failed");
110 if (fetestexcept (FE_UNDERFLOW
) == 0)
112 puts ("nexttowardf- did not underflow");
116 tl
= (long double) DBL_MAX
+ 1.0e305L
;
117 double di
= INFINITY
;
119 feclearexcept (FE_ALL_EXCEPT
);
120 if (nexttoward (dm
, tl
) != di
)
122 puts ("nexttoward+ failed");
125 if (fetestexcept (FE_OVERFLOW
) == 0)
127 puts ("nexttoward+ did not overflow");
130 feclearexcept (FE_ALL_EXCEPT
);
131 if (nexttoward (-dm
, -tl
) != -di
)
133 puts ("nexttoward- failed");
136 if (fetestexcept (FE_OVERFLOW
) == 0)
138 puts ("nexttoward- did not overflow");
144 feclearexcept (FE_ALL_EXCEPT
);
145 di
= nexttoward (dm
, di
);
146 if (di
< 0 || di
>= DBL_MIN
)
148 puts ("nexttoward+ failed");
151 if (fetestexcept (FE_UNDERFLOW
) == 0)
153 puts ("nexttoward+ did not underflow");
157 feclearexcept (FE_ALL_EXCEPT
);
158 di
= nexttoward (-dm
, -di
);
159 if (di
> 0 || di
<= -DBL_MIN
)
161 puts ("nexttoward- failed");
164 if (fetestexcept (FE_UNDERFLOW
) == 0)
166 puts ("nexttoward- did not underflow");
170 feclearexcept (FE_ALL_EXCEPT
);
171 dm
= nexttoward (zero
, inf
);
172 if (dm
< 0.0 || dm
>= DBL_MIN
)
174 puts ("nexttoward+ failed");
177 if (fetestexcept (FE_UNDERFLOW
) == 0)
179 puts ("nexttoward+ did not underflow");
182 feclearexcept (FE_ALL_EXCEPT
);
183 if (nexttoward (dm
, di
) != 0.0)
185 puts ("nexttoward+ failed");
188 if (fetestexcept (FE_UNDERFLOW
) == 0)
190 puts ("nexttoward+ did not underflow");
193 feclearexcept (FE_ALL_EXCEPT
);
194 dm
= nexttoward (copysign (zero
, -1.0), -inf
);
195 if (dm
> 0.0 || dm
<= -DBL_MIN
)
197 puts ("nexttoward- failed");
200 if (fetestexcept (FE_UNDERFLOW
) == 0)
202 puts ("nexttoward- did not underflow");
205 feclearexcept (FE_ALL_EXCEPT
);
206 if (nexttoward (dm
, -di
) != 0.0)
208 puts ("nexttoward- failed");
211 if (fetestexcept (FE_UNDERFLOW
) == 0)
213 puts ("nexttoward- did not underflow");
217 #ifndef NO_LONG_DOUBLE
218 long double li
= INFINITY
;
219 long double lm
= LDBL_MAX
;
220 feclearexcept (FE_ALL_EXCEPT
);
221 if (nexttowardl (lm
, li
) != li
)
223 puts ("nexttowardl+ failed");
226 if (fetestexcept (FE_OVERFLOW
) == 0)
228 puts ("nexttowardl+ did not overflow");
231 feclearexcept (FE_ALL_EXCEPT
);
232 if (nexttowardl (-lm
, -li
) != -li
)
234 puts ("nexttowardl failed");
237 if (fetestexcept (FE_OVERFLOW
) == 0)
239 puts ("nexttowardl- did not overflow");
245 feclearexcept (FE_ALL_EXCEPT
);
246 li
= nexttowardl (lm
, li
);
247 if (li
< 0 || li
>= LDBL_MIN
)
249 puts ("nexttowardl+ failed");
252 if (fetestexcept (FE_UNDERFLOW
) == 0)
254 puts ("nexttowardl+ did not underflow");
258 feclearexcept (FE_ALL_EXCEPT
);
259 li
= nexttowardl (-lm
, -li
);
260 if (li
> 0 || li
<= -LDBL_MIN
)
262 puts ("nexttowardl- failed");
265 if (fetestexcept (FE_UNDERFLOW
) == 0)
267 puts ("nexttowardl- did not underflow");
271 feclearexcept (FE_ALL_EXCEPT
);
272 lm
= nexttowardl (zero
, inf
);
273 if (lm
< 0.0 || lm
>= LDBL_MIN
)
275 puts ("nexttowardl+ failed");
278 if (fetestexcept (FE_UNDERFLOW
) == 0)
280 puts ("nexttowardl+ did not underflow");
283 feclearexcept (FE_ALL_EXCEPT
);
284 if (nexttowardl (lm
, li
) != 0.0)
286 puts ("nexttowardl+ failed");
289 if (fetestexcept (FE_UNDERFLOW
) == 0)
291 puts ("nexttowardl+ did not underflow");
294 feclearexcept (FE_ALL_EXCEPT
);
295 lm
= nexttowardl (copysign (zero
, -1.0), -inf
);
296 if (lm
> 0.0 || lm
<= -LDBL_MIN
)
298 puts ("nexttowardl- failed");
301 if (fetestexcept (FE_UNDERFLOW
) == 0)
303 puts ("nexttowardl- did not underflow");
306 feclearexcept (FE_ALL_EXCEPT
);
307 if (nexttowardl (lm
, -li
) != 0.0)
309 puts ("nexttowardl- failed");
312 if (fetestexcept (FE_UNDERFLOW
) == 0)
314 puts ("nexttowardl- did not underflow");