• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <math.h>
11 
12 #include <math.h>
13 #include <type_traits>
14 #include <cassert>
15 
16 #include "hexfloat.h"
17 
test_acos()18 void test_acos()
19 {
20     static_assert((std::is_same<decltype(acos((double)0)), double>::value), "");
21     static_assert((std::is_same<decltype(acosf(0)), float>::value), "");
22     static_assert((std::is_same<decltype(acosl(0)), long double>::value), "");
23     assert(acos(1) == 0);
24 }
25 
test_asin()26 void test_asin()
27 {
28     static_assert((std::is_same<decltype(asin((double)0)), double>::value), "");
29     static_assert((std::is_same<decltype(asinf(0)), float>::value), "");
30     static_assert((std::is_same<decltype(asinl(0)), long double>::value), "");
31     assert(asin(0) == 0);
32 }
33 
test_atan()34 void test_atan()
35 {
36     static_assert((std::is_same<decltype(atan((double)0)), double>::value), "");
37     static_assert((std::is_same<decltype(atanf(0)), float>::value), "");
38     static_assert((std::is_same<decltype(atanl(0)), long double>::value), "");
39     assert(atan(0) == 0);
40 }
41 
test_atan2()42 void test_atan2()
43 {
44     static_assert((std::is_same<decltype(atan2((double)0, (double)0)), double>::value), "");
45     static_assert((std::is_same<decltype(atan2f(0,0)), float>::value), "");
46     static_assert((std::is_same<decltype(atan2l(0,0)), long double>::value), "");
47     assert(atan2(0,1) == 0);
48 }
49 
test_ceil()50 void test_ceil()
51 {
52     static_assert((std::is_same<decltype(ceil((double)0)), double>::value), "");
53     static_assert((std::is_same<decltype(ceilf(0)), float>::value), "");
54     static_assert((std::is_same<decltype(ceill(0)), long double>::value), "");
55     assert(ceil(0) == 0);
56 }
57 
test_cos()58 void test_cos()
59 {
60     static_assert((std::is_same<decltype(cos((double)0)), double>::value), "");
61     static_assert((std::is_same<decltype(cosf(0)), float>::value), "");
62     static_assert((std::is_same<decltype(cosl(0)), long double>::value), "");
63     assert(cos(0) == 1);
64 }
65 
test_cosh()66 void test_cosh()
67 {
68     static_assert((std::is_same<decltype(cosh((double)0)), double>::value), "");
69     static_assert((std::is_same<decltype(coshf(0)), float>::value), "");
70     static_assert((std::is_same<decltype(coshl(0)), long double>::value), "");
71     assert(cosh(0) == 1);
72 }
73 
test_exp()74 void test_exp()
75 {
76     static_assert((std::is_same<decltype(exp((double)0)), double>::value), "");
77     static_assert((std::is_same<decltype(expf(0)), float>::value), "");
78     static_assert((std::is_same<decltype(expl(0)), long double>::value), "");
79     assert(exp(0) == 1);
80 }
81 
test_fabs()82 void test_fabs()
83 {
84     static_assert((std::is_same<decltype(fabs((double)0)), double>::value), "");
85     static_assert((std::is_same<decltype(fabsf(0)), float>::value), "");
86     static_assert((std::is_same<decltype(fabsl(0)), long double>::value), "");
87     assert(fabs(-1) == 1);
88 }
89 
test_floor()90 void test_floor()
91 {
92     static_assert((std::is_same<decltype(floor((double)0)), double>::value), "");
93     static_assert((std::is_same<decltype(floorf(0)), float>::value), "");
94     static_assert((std::is_same<decltype(floorl(0)), long double>::value), "");
95     assert(floor(1) == 1);
96 }
97 
test_fmod()98 void test_fmod()
99 {
100     static_assert((std::is_same<decltype(fmod((double)0, (double)0)), double>::value), "");
101     static_assert((std::is_same<decltype(fmodf(0,0)), float>::value), "");
102     static_assert((std::is_same<decltype(fmodl(0,0)), long double>::value), "");
103     assert(fmod(1.5,1) == .5);
104 }
105 
test_frexp()106 void test_frexp()
107 {
108     int ip;
109     static_assert((std::is_same<decltype(frexp((double)0, &ip)), double>::value), "");
110     static_assert((std::is_same<decltype(frexpf(0, &ip)), float>::value), "");
111     static_assert((std::is_same<decltype(frexpl(0, &ip)), long double>::value), "");
112     assert(frexp(0, &ip) == 0);
113 }
114 
test_ldexp()115 void test_ldexp()
116 {
117     int ip = 1;
118     static_assert((std::is_same<decltype(ldexp((double)0, ip)), double>::value), "");
119     static_assert((std::is_same<decltype(ldexpf(0, ip)), float>::value), "");
120     static_assert((std::is_same<decltype(ldexpl(0, ip)), long double>::value), "");
121     assert(ldexp(1, ip) == 2);
122 }
123 
test_log()124 void test_log()
125 {
126     static_assert((std::is_same<decltype(log((double)0)), double>::value), "");
127     static_assert((std::is_same<decltype(logf(0)), float>::value), "");
128     static_assert((std::is_same<decltype(logl(0)), long double>::value), "");
129     assert(log(1) == 0);
130 }
131 
test_log10()132 void test_log10()
133 {
134     static_assert((std::is_same<decltype(log10((double)0)), double>::value), "");
135     static_assert((std::is_same<decltype(log10f(0)), float>::value), "");
136     static_assert((std::is_same<decltype(log10l(0)), long double>::value), "");
137     assert(log10(1) == 0);
138 }
139 
test_modf()140 void test_modf()
141 {
142     static_assert((std::is_same<decltype(modf((double)0, (double*)0)), double>::value), "");
143     static_assert((std::is_same<decltype(modff(0, (float*)0)), float>::value), "");
144     static_assert((std::is_same<decltype(modfl(0, (long double*)0)), long double>::value), "");
145     double i;
146     assert(modf(1., &i) == 0);
147 }
148 
test_pow()149 void test_pow()
150 {
151     static_assert((std::is_same<decltype(pow((double)0, (double)0)), double>::value), "");
152     static_assert((std::is_same<decltype(powf(0,0)), float>::value), "");
153     static_assert((std::is_same<decltype(powl(0,0)), long double>::value), "");
154     assert(pow(1,1) == 1);
155 }
156 
test_sin()157 void test_sin()
158 {
159     static_assert((std::is_same<decltype(sin((double)0)), double>::value), "");
160     static_assert((std::is_same<decltype(sinf(0)), float>::value), "");
161     static_assert((std::is_same<decltype(sinl(0)), long double>::value), "");
162     assert(sin(0) == 0);
163 }
164 
test_sinh()165 void test_sinh()
166 {
167     static_assert((std::is_same<decltype(sinh((double)0)), double>::value), "");
168     static_assert((std::is_same<decltype(sinhf(0)), float>::value), "");
169     static_assert((std::is_same<decltype(sinhl(0)), long double>::value), "");
170     assert(sinh(0) == 0);
171 }
172 
test_sqrt()173 void test_sqrt()
174 {
175     static_assert((std::is_same<decltype(sqrt((double)0)), double>::value), "");
176     static_assert((std::is_same<decltype(sqrtf(0)), float>::value), "");
177     static_assert((std::is_same<decltype(sqrtl(0)), long double>::value), "");
178     assert(sqrt(4) == 2);
179 }
180 
test_tan()181 void test_tan()
182 {
183     static_assert((std::is_same<decltype(tan((double)0)), double>::value), "");
184     static_assert((std::is_same<decltype(tanf(0)), float>::value), "");
185     static_assert((std::is_same<decltype(tanl(0)), long double>::value), "");
186     assert(tan(0) == 0);
187 }
188 
test_tanh()189 void test_tanh()
190 {
191     static_assert((std::is_same<decltype(tanh((double)0)), double>::value), "");
192     static_assert((std::is_same<decltype(tanhf(0)), float>::value), "");
193     static_assert((std::is_same<decltype(tanhl(0)), long double>::value), "");
194     assert(tanh(0) == 0);
195 }
196 
test_signbit()197 void test_signbit()
198 {
199     static_assert((std::is_same<decltype(signbit((float)0)), bool>::value), "");
200     static_assert((std::is_same<decltype(signbit((double)0)), bool>::value), "");
201     static_assert((std::is_same<decltype(signbit((long double)0)), bool>::value), "");
202     assert(signbit(-1.0) == true);
203 }
204 
test_fpclassify()205 void test_fpclassify()
206 {
207     static_assert((std::is_same<decltype(fpclassify((float)0)), int>::value), "");
208     static_assert((std::is_same<decltype(fpclassify((double)0)), int>::value), "");
209     static_assert((std::is_same<decltype(fpclassify((long double)0)), int>::value), "");
210     assert(fpclassify(-1.0) == FP_NORMAL);
211 }
212 
test_isfinite()213 void test_isfinite()
214 {
215     static_assert((std::is_same<decltype(isfinite((float)0)), bool>::value), "");
216     static_assert((std::is_same<decltype(isfinite((double)0)), bool>::value), "");
217     static_assert((std::is_same<decltype(isfinite((long double)0)), bool>::value), "");
218     assert(isfinite(-1.0) == true);
219 }
220 
test_isinf()221 void test_isinf()
222 {
223     static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), "");
224     static_assert((std::is_same<decltype(isinf((double)0)), bool>::value), "");
225     static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), "");
226     assert(isinf(-1.0) == false);
227 }
228 
test_isnan()229 void test_isnan()
230 {
231     static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), "");
232     static_assert((std::is_same<decltype(isnan((double)0)), bool>::value), "");
233     static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), "");
234     assert(isnan(-1.0) == false);
235 }
236 
test_isnormal()237 void test_isnormal()
238 {
239     static_assert((std::is_same<decltype(isnormal((float)0)), bool>::value), "");
240     static_assert((std::is_same<decltype(isnormal((double)0)), bool>::value), "");
241     static_assert((std::is_same<decltype(isnormal((long double)0)), bool>::value), "");
242     assert(isnormal(-1.0) == true);
243 }
244 
test_isgreater()245 void test_isgreater()
246 {
247     static_assert((std::is_same<decltype(isgreater((float)0, (float)0)), bool>::value), "");
248     static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), bool>::value), "");
249     static_assert((std::is_same<decltype(isgreater((float)0, (long double)0)), bool>::value), "");
250     static_assert((std::is_same<decltype(isgreater((double)0, (float)0)), bool>::value), "");
251     static_assert((std::is_same<decltype(isgreater((double)0, (double)0)), bool>::value), "");
252     static_assert((std::is_same<decltype(isgreater((double)0, (long double)0)), bool>::value), "");
253     static_assert((std::is_same<decltype(isgreater((long double)0, (float)0)), bool>::value), "");
254     static_assert((std::is_same<decltype(isgreater((long double)0, (double)0)), bool>::value), "");
255     static_assert((std::is_same<decltype(isgreater((long double)0, (long double)0)), bool>::value), "");
256     assert(isgreater(-1.0, 0.F) == false);
257 }
258 
test_isgreaterequal()259 void test_isgreaterequal()
260 {
261     static_assert((std::is_same<decltype(isgreaterequal((float)0, (float)0)), bool>::value), "");
262     static_assert((std::is_same<decltype(isgreaterequal((float)0, (double)0)), bool>::value), "");
263     static_assert((std::is_same<decltype(isgreaterequal((float)0, (long double)0)), bool>::value), "");
264     static_assert((std::is_same<decltype(isgreaterequal((double)0, (float)0)), bool>::value), "");
265     static_assert((std::is_same<decltype(isgreaterequal((double)0, (double)0)), bool>::value), "");
266     static_assert((std::is_same<decltype(isgreaterequal((double)0, (long double)0)), bool>::value), "");
267     static_assert((std::is_same<decltype(isgreaterequal((long double)0, (float)0)), bool>::value), "");
268     static_assert((std::is_same<decltype(isgreaterequal((long double)0, (double)0)), bool>::value), "");
269     static_assert((std::is_same<decltype(isgreaterequal((long double)0, (long double)0)), bool>::value), "");
270     assert(isgreaterequal(-1.0, 0.F) == false);
271 }
272 
test_isless()273 void test_isless()
274 {
275     static_assert((std::is_same<decltype(isless((float)0, (float)0)), bool>::value), "");
276     static_assert((std::is_same<decltype(isless((float)0, (double)0)), bool>::value), "");
277     static_assert((std::is_same<decltype(isless((float)0, (long double)0)), bool>::value), "");
278     static_assert((std::is_same<decltype(isless((double)0, (float)0)), bool>::value), "");
279     static_assert((std::is_same<decltype(isless((double)0, (double)0)), bool>::value), "");
280     static_assert((std::is_same<decltype(isless((double)0, (long double)0)), bool>::value), "");
281     static_assert((std::is_same<decltype(isless((long double)0, (float)0)), bool>::value), "");
282     static_assert((std::is_same<decltype(isless((long double)0, (double)0)), bool>::value), "");
283     static_assert((std::is_same<decltype(isless((long double)0, (long double)0)), bool>::value), "");
284     assert(isless(-1.0, 0.F) == true);
285 }
286 
test_islessequal()287 void test_islessequal()
288 {
289     static_assert((std::is_same<decltype(islessequal((float)0, (float)0)), bool>::value), "");
290     static_assert((std::is_same<decltype(islessequal((float)0, (double)0)), bool>::value), "");
291     static_assert((std::is_same<decltype(islessequal((float)0, (long double)0)), bool>::value), "");
292     static_assert((std::is_same<decltype(islessequal((double)0, (float)0)), bool>::value), "");
293     static_assert((std::is_same<decltype(islessequal((double)0, (double)0)), bool>::value), "");
294     static_assert((std::is_same<decltype(islessequal((double)0, (long double)0)), bool>::value), "");
295     static_assert((std::is_same<decltype(islessequal((long double)0, (float)0)), bool>::value), "");
296     static_assert((std::is_same<decltype(islessequal((long double)0, (double)0)), bool>::value), "");
297     static_assert((std::is_same<decltype(islessequal((long double)0, (long double)0)), bool>::value), "");
298     assert(islessequal(-1.0, 0.F) == true);
299 }
300 
test_islessgreater()301 void test_islessgreater()
302 {
303     static_assert((std::is_same<decltype(islessgreater((float)0, (float)0)), bool>::value), "");
304     static_assert((std::is_same<decltype(islessgreater((float)0, (double)0)), bool>::value), "");
305     static_assert((std::is_same<decltype(islessgreater((float)0, (long double)0)), bool>::value), "");
306     static_assert((std::is_same<decltype(islessgreater((double)0, (float)0)), bool>::value), "");
307     static_assert((std::is_same<decltype(islessgreater((double)0, (double)0)), bool>::value), "");
308     static_assert((std::is_same<decltype(islessgreater((double)0, (long double)0)), bool>::value), "");
309     static_assert((std::is_same<decltype(islessgreater((long double)0, (float)0)), bool>::value), "");
310     static_assert((std::is_same<decltype(islessgreater((long double)0, (double)0)), bool>::value), "");
311     static_assert((std::is_same<decltype(islessgreater((long double)0, (long double)0)), bool>::value), "");
312     assert(islessgreater(-1.0, 0.F) == true);
313 }
314 
test_isunordered()315 void test_isunordered()
316 {
317     static_assert((std::is_same<decltype(isunordered((float)0, (float)0)), bool>::value), "");
318     static_assert((std::is_same<decltype(isunordered((float)0, (double)0)), bool>::value), "");
319     static_assert((std::is_same<decltype(isunordered((float)0, (long double)0)), bool>::value), "");
320     static_assert((std::is_same<decltype(isunordered((double)0, (float)0)), bool>::value), "");
321     static_assert((std::is_same<decltype(isunordered((double)0, (double)0)), bool>::value), "");
322     static_assert((std::is_same<decltype(isunordered((double)0, (long double)0)), bool>::value), "");
323     static_assert((std::is_same<decltype(isunordered((long double)0, (float)0)), bool>::value), "");
324     static_assert((std::is_same<decltype(isunordered((long double)0, (double)0)), bool>::value), "");
325     static_assert((std::is_same<decltype(isunordered((long double)0, (long double)0)), bool>::value), "");
326     assert(isunordered(-1.0, 0.F) == false);
327 }
328 
test_acosh()329 void test_acosh()
330 {
331     static_assert((std::is_same<decltype(acosh((double)0)), double>::value), "");
332     static_assert((std::is_same<decltype(acoshf(0)), float>::value), "");
333     static_assert((std::is_same<decltype(acoshl(0)), long double>::value), "");
334     assert(acosh(1) == 0);
335 }
336 
test_asinh()337 void test_asinh()
338 {
339     static_assert((std::is_same<decltype(asinh((double)0)), double>::value), "");
340     static_assert((std::is_same<decltype(asinhf(0)), float>::value), "");
341     static_assert((std::is_same<decltype(asinhl(0)), long double>::value), "");
342     assert(asinh(0) == 0);
343 }
344 
test_atanh()345 void test_atanh()
346 {
347     static_assert((std::is_same<decltype(atanh((double)0)), double>::value), "");
348     static_assert((std::is_same<decltype(atanhf(0)), float>::value), "");
349     static_assert((std::is_same<decltype(atanhl(0)), long double>::value), "");
350     assert(atanh(0) == 0);
351 }
352 
test_cbrt()353 void test_cbrt()
354 {
355     static_assert((std::is_same<decltype(cbrt((double)0)), double>::value), "");
356     static_assert((std::is_same<decltype(cbrtf(0)), float>::value), "");
357     static_assert((std::is_same<decltype(cbrtl(0)), long double>::value), "");
358     assert(cbrt(1) == 1);
359 }
360 
test_copysign()361 void test_copysign()
362 {
363     static_assert((std::is_same<decltype(copysign((double)0, (double)0)), double>::value), "");
364     static_assert((std::is_same<decltype(copysignf(0,0)), float>::value), "");
365     static_assert((std::is_same<decltype(copysignl(0,0)), long double>::value), "");
366     assert(copysign(1,1) == 1);
367 }
368 
test_erf()369 void test_erf()
370 {
371     static_assert((std::is_same<decltype(erf((double)0)), double>::value), "");
372     static_assert((std::is_same<decltype(erff(0)), float>::value), "");
373     static_assert((std::is_same<decltype(erfl(0)), long double>::value), "");
374     assert(erf(0) == 0);
375 }
376 
test_erfc()377 void test_erfc()
378 {
379     static_assert((std::is_same<decltype(erfc((double)0)), double>::value), "");
380     static_assert((std::is_same<decltype(erfcf(0)), float>::value), "");
381     static_assert((std::is_same<decltype(erfcl(0)), long double>::value), "");
382     assert(erfc(0) == 1);
383 }
384 
test_exp2()385 void test_exp2()
386 {
387     static_assert((std::is_same<decltype(exp2((double)0)), double>::value), "");
388     static_assert((std::is_same<decltype(exp2f(0)), float>::value), "");
389     static_assert((std::is_same<decltype(exp2l(0)), long double>::value), "");
390     assert(exp2(1) == 2);
391 }
392 
test_expm1()393 void test_expm1()
394 {
395     static_assert((std::is_same<decltype(expm1((double)0)), double>::value), "");
396     static_assert((std::is_same<decltype(expm1f(0)), float>::value), "");
397     static_assert((std::is_same<decltype(expm1l(0)), long double>::value), "");
398     assert(expm1(0) == 0);
399 }
400 
test_fdim()401 void test_fdim()
402 {
403     static_assert((std::is_same<decltype(fdim((double)0, (double)0)), double>::value), "");
404     static_assert((std::is_same<decltype(fdimf(0,0)), float>::value), "");
405     static_assert((std::is_same<decltype(fdiml(0,0)), long double>::value), "");
406     assert(fdim(1,0) == 1);
407 }
408 
test_fma()409 void test_fma()
410 {
411     static_assert((std::is_same<decltype(fma((double)0, (double)0,  (double)0)), double>::value), "");
412     static_assert((std::is_same<decltype(fmaf(0,0,0)), float>::value), "");
413     static_assert((std::is_same<decltype(fmal(0,0,0)), long double>::value), "");
414     assert(fma(1,1,1) == 2);
415 }
416 
test_fmax()417 void test_fmax()
418 {
419     static_assert((std::is_same<decltype(fmax((double)0, (double)0)), double>::value), "");
420     static_assert((std::is_same<decltype(fmaxf(0,0)), float>::value), "");
421     static_assert((std::is_same<decltype(fmaxl(0,0)), long double>::value), "");
422     assert(fmax(1,0) == 1);
423 }
424 
test_fmin()425 void test_fmin()
426 {
427     static_assert((std::is_same<decltype(fmin((double)0, (double)0)), double>::value), "");
428     static_assert((std::is_same<decltype(fminf(0,0)), float>::value), "");
429     static_assert((std::is_same<decltype(fminl(0,0)), long double>::value), "");
430     assert(fmin(1,0) == 0);
431 }
432 
test_hypot()433 void test_hypot()
434 {
435     static_assert((std::is_same<decltype(hypot((double)0, (double)0)), double>::value), "");
436     static_assert((std::is_same<decltype(hypotf(0,0)), float>::value), "");
437     static_assert((std::is_same<decltype(hypotl(0,0)), long double>::value), "");
438     assert(hypot(3,4) == 5);
439 }
440 
test_ilogb()441 void test_ilogb()
442 {
443     static_assert((std::is_same<decltype(ilogb((double)0)), int>::value), "");
444     static_assert((std::is_same<decltype(ilogbf(0)), int>::value), "");
445     static_assert((std::is_same<decltype(ilogbl(0)), int>::value), "");
446     assert(ilogb(1) == 0);
447 }
448 
test_lgamma()449 void test_lgamma()
450 {
451     static_assert((std::is_same<decltype(lgamma((double)0)), double>::value), "");
452     static_assert((std::is_same<decltype(lgammaf(0)), float>::value), "");
453     static_assert((std::is_same<decltype(lgammal(0)), long double>::value), "");
454     assert(lgamma(1) == 0);
455 }
456 
test_llrint()457 void test_llrint()
458 {
459     static_assert((std::is_same<decltype(llrint((double)0)), long long>::value), "");
460     static_assert((std::is_same<decltype(llrintf(0)), long long>::value), "");
461     static_assert((std::is_same<decltype(llrintl(0)), long long>::value), "");
462     assert(llrint(1) == 1LL);
463 }
464 
test_llround()465 void test_llround()
466 {
467     static_assert((std::is_same<decltype(llround((double)0)), long long>::value), "");
468     static_assert((std::is_same<decltype(llroundf(0)), long long>::value), "");
469     static_assert((std::is_same<decltype(llroundl(0)), long long>::value), "");
470     assert(llround(1) == 1LL);
471 }
472 
test_log1p()473 void test_log1p()
474 {
475     static_assert((std::is_same<decltype(log1p((double)0)), double>::value), "");
476     static_assert((std::is_same<decltype(log1pf(0)), float>::value), "");
477     static_assert((std::is_same<decltype(log1pl(0)), long double>::value), "");
478     assert(log1p(0) == 0);
479 }
480 
test_log2()481 void test_log2()
482 {
483     static_assert((std::is_same<decltype(log2((double)0)), double>::value), "");
484     static_assert((std::is_same<decltype(log2f(0)), float>::value), "");
485     static_assert((std::is_same<decltype(log2l(0)), long double>::value), "");
486     assert(log2(1) == 0);
487 }
488 
test_logb()489 void test_logb()
490 {
491     static_assert((std::is_same<decltype(logb((double)0)), double>::value), "");
492     static_assert((std::is_same<decltype(logbf(0)), float>::value), "");
493     static_assert((std::is_same<decltype(logbl(0)), long double>::value), "");
494     assert(logb(1) == 0);
495 }
496 
test_lrint()497 void test_lrint()
498 {
499     static_assert((std::is_same<decltype(lrint((double)0)), long>::value), "");
500     static_assert((std::is_same<decltype(lrintf(0)), long>::value), "");
501     static_assert((std::is_same<decltype(lrintl(0)), long>::value), "");
502     assert(lrint(1) == 1L);
503 }
504 
test_lround()505 void test_lround()
506 {
507     static_assert((std::is_same<decltype(lround((double)0)), long>::value), "");
508     static_assert((std::is_same<decltype(lroundf(0)), long>::value), "");
509     static_assert((std::is_same<decltype(lroundl(0)), long>::value), "");
510     assert(lround(1) == 1L);
511 }
512 
test_nan()513 void test_nan()
514 {
515     static_assert((std::is_same<decltype(nan("")), double>::value), "");
516     static_assert((std::is_same<decltype(nanf("")), float>::value), "");
517     static_assert((std::is_same<decltype(nanl("")), long double>::value), "");
518 }
519 
test_nearbyint()520 void test_nearbyint()
521 {
522     static_assert((std::is_same<decltype(nearbyint((double)0)), double>::value), "");
523     static_assert((std::is_same<decltype(nearbyintf(0)), float>::value), "");
524     static_assert((std::is_same<decltype(nearbyintl(0)), long double>::value), "");
525     assert(nearbyint(1) == 1);
526 }
527 
test_nextafter()528 void test_nextafter()
529 {
530     static_assert((std::is_same<decltype(nextafter((double)0, (double)0)), double>::value), "");
531     static_assert((std::is_same<decltype(nextafterf(0,0)), float>::value), "");
532     static_assert((std::is_same<decltype(nextafterl(0,0)), long double>::value), "");
533     assert(nextafter(0,1) == hexfloat<double>(0x1, 0, -1074));
534 }
535 
test_nexttoward()536 void test_nexttoward()
537 {
538     static_assert((std::is_same<decltype(nexttoward((double)0, (long double)0)), double>::value), "");
539     static_assert((std::is_same<decltype(nexttowardf(0, (long double)0)), float>::value), "");
540     static_assert((std::is_same<decltype(nexttowardl(0, (long double)0)), long double>::value), "");
541     assert(nexttoward(0, 1) == hexfloat<double>(0x1, 0, -1074));
542 }
543 
test_remainder()544 void test_remainder()
545 {
546     static_assert((std::is_same<decltype(remainder((double)0, (double)0)), double>::value), "");
547     static_assert((std::is_same<decltype(remainderf(0,0)), float>::value), "");
548     static_assert((std::is_same<decltype(remainderl(0,0)), long double>::value), "");
549     static_assert((std::is_same<decltype(remainder((int)0, (int)0)), double>::value), "");
550     assert(remainder(0.5,1) == 0.5);
551 }
552 
test_remquo()553 void test_remquo()
554 {
555     int ip;
556     static_assert((std::is_same<decltype(remquo((double)0, (double)0, &ip)), double>::value), "");
557     static_assert((std::is_same<decltype(remquof(0,0, &ip)), float>::value), "");
558     static_assert((std::is_same<decltype(remquol(0,0, &ip)), long double>::value), "");
559     assert(remquo(0.5,1, &ip) == 0.5);
560 }
561 
test_rint()562 void test_rint()
563 {
564     static_assert((std::is_same<decltype(rint((double)0)), double>::value), "");
565     static_assert((std::is_same<decltype(rintf(0)), float>::value), "");
566     static_assert((std::is_same<decltype(rintl(0)), long double>::value), "");
567     assert(rint(1) == 1);
568 }
569 
test_round()570 void test_round()
571 {
572     static_assert((std::is_same<decltype(round((double)0)), double>::value), "");
573     static_assert((std::is_same<decltype(roundf(0)), float>::value), "");
574     static_assert((std::is_same<decltype(roundl(0)), long double>::value), "");
575     assert(round(1) == 1);
576 }
577 
test_scalbln()578 void test_scalbln()
579 {
580     static_assert((std::is_same<decltype(scalbln((double)0, (long)0)), double>::value), "");
581     static_assert((std::is_same<decltype(scalblnf(0, (long)0)), float>::value), "");
582     static_assert((std::is_same<decltype(scalblnl(0, (long)0)), long double>::value), "");
583     assert(scalbln(1, 1) == 2);
584 }
585 
test_scalbn()586 void test_scalbn()
587 {
588     static_assert((std::is_same<decltype(scalbn((double)0, (int)0)), double>::value), "");
589     static_assert((std::is_same<decltype(scalbnf(0, (int)0)), float>::value), "");
590     static_assert((std::is_same<decltype(scalbnl(0, (int)0)), long double>::value), "");
591     assert(scalbn(1, 1) == 2);
592 }
593 
test_tgamma()594 void test_tgamma()
595 {
596     static_assert((std::is_same<decltype(tgamma((double)0)), double>::value), "");
597     static_assert((std::is_same<decltype(tgammaf(0)), float>::value), "");
598     static_assert((std::is_same<decltype(tgammal(0)), long double>::value), "");
599     assert(tgamma(1) == 1);
600 }
601 
test_trunc()602 void test_trunc()
603 {
604     static_assert((std::is_same<decltype(trunc((double)0)), double>::value), "");
605     static_assert((std::is_same<decltype(truncf(0)), float>::value), "");
606     static_assert((std::is_same<decltype(truncl(0)), long double>::value), "");
607     assert(trunc(1) == 1);
608 }
609 
main()610 int main()
611 {
612     test_acos();
613     test_asin();
614     test_atan();
615     test_atan2();
616     test_ceil();
617     test_cos();
618     test_cosh();
619     test_exp();
620     test_fabs();
621     test_floor();
622     test_fmod();
623     test_frexp();
624     test_ldexp();
625     test_log();
626     test_log10();
627     test_modf();
628     test_pow();
629     test_sin();
630     test_sinh();
631     test_sqrt();
632     test_tan();
633     test_tanh();
634     test_signbit();
635     test_fpclassify();
636     test_isfinite();
637     test_isinf();
638     test_isnan();
639     test_isnormal();
640     test_isgreater();
641     test_isgreaterequal();
642     test_isless();
643     test_islessequal();
644     test_islessgreater();
645     test_isunordered();
646     test_acosh();
647     test_asinh();
648     test_atanh();
649     test_cbrt();
650     test_copysign();
651     test_erf();
652     test_erfc();
653     test_exp2();
654     test_expm1();
655     test_fdim();
656     test_fma();
657     test_fmax();
658     test_fmin();
659     test_hypot();
660     test_ilogb();
661     test_lgamma();
662     test_llrint();
663     test_llround();
664     test_log1p();
665     test_log2();
666     test_logb();
667     test_lrint();
668     test_lround();
669     test_nan();
670     test_nearbyint();
671     test_nextafter();
672     test_nexttoward();
673     test_remainder();
674     test_remquo();
675     test_rint();
676     test_round();
677     test_scalbln();
678     test_scalbn();
679     test_tgamma();
680     test_trunc();
681 }
682