diff options
author | das <das@FreeBSD.org> | 2008-08-07 14:39:56 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2008-08-07 14:39:56 +0000 |
commit | 1a05561e3440bd40c2aeaeb7b9369c3e0f3b5852 (patch) | |
tree | d63035ed872a363bf437b7f32c5b4dc4d50b47d4 /lib/msun/src/s_conjf.c | |
parent | f9ebb230ca1b1ab7963cd38728716b73299417dc (diff) | |
download | FreeBSD-src-1a05561e3440bd40c2aeaeb7b9369c3e0f3b5852.zip FreeBSD-src-1a05561e3440bd40c2aeaeb7b9369c3e0f3b5852.tar.gz |
Use cpack() and the gcc extension __imag__ to implement cimag() and
conj() instead of using expressions like z * I. The latter is bad for
several reasons:
1. It is implemented using arithmetic, which is unnecessary, and can
generate floating point exceptions, contrary to the requirements on
these functions.
2. gcc implements complex multiplication using a formula that breaks
down for infinities, e.g., it gives INFINITY * I == nan + inf I.
Diffstat (limited to 'lib/msun/src/s_conjf.c')
-rw-r--r-- | lib/msun/src/s_conjf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/msun/src/s_conjf.c b/lib/msun/src/s_conjf.c index ea951b9..b090760 100644 --- a/lib/msun/src/s_conjf.c +++ b/lib/msun/src/s_conjf.c @@ -28,8 +28,11 @@ #include <complex.h> +#include "math_private.h" + float complex conjf(float complex z) { - return crealf(z) - I * cimagf(z); + + return (cpackf(crealf(z), -cimagf(z))); } |