about summary refs log tree commit diff
path: root/sysdeps/libm-ieee754/s_csqrtl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-ieee754/s_csqrtl.c')
-rw-r--r--sysdeps/libm-ieee754/s_csqrtl.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sysdeps/libm-ieee754/s_csqrtl.c b/sysdeps/libm-ieee754/s_csqrtl.c
index 3de7310c73..b772709947 100644
--- a/sysdeps/libm-ieee754/s_csqrtl.c
+++ b/sysdeps/libm-ieee754/s_csqrtl.c
@@ -84,6 +84,7 @@ __csqrtl (__complex__ long double x)
 	}
       else
 	{
+#if 0 /* FIXME: this is broken. */
 	  __complex__ long double q;
 	  long double t, r;
 
@@ -99,6 +100,15 @@ __csqrtl (__complex__ long double x)
 
 	  /* Heron iteration in complex arithmetic.  */
 	  res = 0.5 * (q + q / x);
+#else
+	  long double d, imag;
+
+	  d = __ieee754_hypotl (__real__ x, __imag__ x);
+	  imag = __ieee754_sqrtl (0.5 * (d - __real__ x));
+
+	  __real__ res = __ieee754_sqrtl (0.5 * (d + __real__ x));
+	  __imag__ res = __copysignl (imag, __imag__ x);
+#endif
 	}
     }