diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/complex/_Complex_I.c | 4 | ||||
| -rw-r--r-- | src/complex/cimag.c | 6 | ||||
| -rw-r--r-- | src/complex/conj.c | 2 | ||||
| -rw-r--r-- | src/complex/creal.c | 6 |
4 files changed, 14 insertions, 4 deletions
diff --git a/src/complex/_Complex_I.c b/src/complex/_Complex_I.c index 0cb6aede..a250d031 100644 --- a/src/complex/_Complex_I.c +++ b/src/complex/_Complex_I.c @@ -1,6 +1,8 @@ #include <complex.h> -#define _Complex_I (const float _Complex)1 /* TODO: imaginary unit */ +#define _Complex_I \ + (((union { _Complex float __c; float __f[2]; }){.__f = {0., 1.} }).__c) + /* STDC(199901) diff --git a/src/complex/cimag.c b/src/complex/cimag.c index 414ecdba..c08ae122 100644 --- a/src/complex/cimag.c +++ b/src/complex/cimag.c @@ -5,7 +5,11 @@ TYPE TGFN(cimag)(TYPE complex z) { - return 0.0; + union { + complex TYPE c; + TYPE f[2]; + } u = { .c = z }; + return z[1]; } /*d diff --git a/src/complex/conj.c b/src/complex/conj.c index f1631106..18e50c9c 100644 --- a/src/complex/conj.c +++ b/src/complex/conj.c @@ -5,7 +5,7 @@ TYPE complex TGFN(conj)(TYPE complex z) { - return 0.0; + return TGFN(creal)(z) - TGFN(cimag)(z); } /*d diff --git a/src/complex/creal.c b/src/complex/creal.c index 86f3cb1b..eac2576e 100644 --- a/src/complex/creal.c +++ b/src/complex/creal.c @@ -5,7 +5,11 @@ TYPE TGFN(creal)(TYPE complex z) { - return 0.0; + union { + complex TYPE c; + TYPE f[2]; + } u = { .c = z }; + return z[0]; } /*d |
