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