1 /* $OpenBSD: complex.c,v 1.2 2015/07/16 13:42:06 martynas Exp $ */
2
3 /*
4 * Written by Martynas Venckus. Public domain
5 */
6
7 #include <assert.h>
8 #include <complex.h>
9 #include <math.h>
10
11 #define PREC 1000
12 #define test(f, r, i) ( \
13 floor((__real__ (f)) * PREC) == floor((r) * PREC) && \
14 floor((__imag__ (f)) * PREC) == floor((i) * PREC) \
15 )
16 #define testf(f, r, i) ( \
17 floorf((__real__ (f)) * PREC) == floorf((r) * PREC) && \
18 floorf((__imag__ (f)) * PREC) == floorf((i) * PREC) \
19 )
20 #define testl(f, r, i) ( \
21 floorl((__real__ (f)) * PREC) == floorl((r) * PREC) && \
22 floorl((__imag__ (f)) * PREC) == floorl((i) * PREC) \
23 )
24
25 int
main(int argc,char * argv[])26 main(int argc, char *argv[])
27 {
28 double complex r, z4 = -1.1 - 1.1 * I;
29 float complex rf, z4f = -1.1F - 1.1F * I;
30 long double complex rl, z4l = -1.1L - 1.1L * I;
31
32 r = cacosh(z4);
33 assert(test(r, 1.150127, -2.256295));
34 r = casinh(z4);
35 assert(test(r, -1.150127, -0.685498));
36 r = catanh(z4);
37 assert(test(r, -0.381870, -1.071985));
38
39 rf = cacoshf(z4f);
40 assert(testf(rf, 1.150127F, -2.256295F));
41 rf = casinhf(z4f);
42 assert(testf(rf, -1.150127F, -0.685498F));
43 rf = catanhf(z4f);
44 assert(testf(rf, -0.381870F, -1.071985F));
45
46 rl = cacoshl(z4l);
47 assert(testl(rl, 1.150127L, -2.256295L));
48 rl = casinhl(z4l);
49 assert(testl(rl, -1.150127L, -0.685498L));
50 rl = catanhl(z4l);
51 assert(testl(rl, -0.381870L, -1.071985L));
52
53 return (0);
54 }
55