8720feb489f4c6b861098ee81db234b40257f094
[libm] / src / cmath / conj.c
1 #include "libm.h"
2
3 // nice, but internally ugly:
4 // macros generate gratuitous code the compiler has to optimize away
5 double complex conj(double complex z)
6 {
7         return cpack(creal(z), -cimag(z));
8 }
9
10 /*
11 // always works, but ugly union
12 double complex conj(double complex z) {
13         union dcomplex u = {z};
14
15         u.a[1] = -u.a[1];
16         return u.z;
17 }
18
19 // reasonable, needs clever compiler that understands *I
20 double complex conj(double complex z) {
21         return creal(z) - cimag(z)*I;
22 }
23 */