about summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
authorRichard B. Kreckel <kreckel@ginac.de>2011-12-21 21:01:29 -0500
committerUlrich Drepper <drepper@gmail.com>2011-12-21 21:01:29 -0500
commitb27e24b8746b20d9ded426f202b79c3b7aeb953e (patch)
treecc534a882fbcf7498e22743335b3d2bcfd820cac /math
parent60e8585f2a2aa288a403a581f1dc8d3fc373598b (diff)
downloadglibc-b27e24b8746b20d9ded426f202b79c3b7aeb953e.tar.gz
glibc-b27e24b8746b20d9ded426f202b79c3b7aeb953e.tar.xz
glibc-b27e24b8746b20d9ded426f202b79c3b7aeb953e.zip
Fix sign errr in some cacosh results
Diffstat (limited to 'math')
-rw-r--r--math/s_cacosh.c6
-rw-r--r--math/s_cacoshf.c22
-rw-r--r--math/s_cacoshl.c6
3 files changed, 4 insertions, 30 deletions
diff --git a/math/s_cacosh.c b/math/s_cacosh.c
index bec6d3827e..df5ce6945d 100644
--- a/math/s_cacosh.c
+++ b/math/s_cacosh.c
@@ -74,17 +74,13 @@ __cacosh (__complex__ double x)
 
       y = __csqrt (y);
 
-      if (__real__ x < 0.0)
+      if (signbit (__real__ x))
 	y = -y;
 
       __real__ y += __real__ x;
       __imag__ y += __imag__ x;
 
       res = __clog (y);
-
-      /* We have to use the positive branch.  */
-      if (__real__ res < 0.0)
-	res = -res;
     }
 
   return res;
diff --git a/math/s_cacoshf.c b/math/s_cacoshf.c
index 0d6bd75dd7..aa4696f10b 100644
--- a/math/s_cacoshf.c
+++ b/math/s_cacoshf.c
@@ -1,5 +1,5 @@
 /* Return arc hyperbole cosine for float value.
-   Copyright (C) 1997, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2006, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -67,7 +67,6 @@ __cacoshf (__complex__ float x)
     }
   else
     {
-#if 1
       __complex__ float y;
 
       __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0;
@@ -75,30 +74,13 @@ __cacoshf (__complex__ float x)
 
       y = __csqrtf (y);
 
-      if (__real__ x < 0.0)
+      if (signbit (__real__ x))
 	y = -y;
 
       __real__ y += __real__ x;
       __imag__ y += __imag__ x;
 
       res = __clogf (y);
-#else
-      float re2 = __real__ x * __real__ x;
-      float im2 = __imag__ x * __imag__ x;
-      float sq = re2 - im2 - 1.0;
-      float ro = __ieee754_sqrtf (sq * sq + 4 * re2 * im2);
-      float a = __ieee754_sqrtf ((sq + ro) / 2.0);
-      float b = __ieee754_sqrtf ((-sq + ro) / 2.0);
-
-      __real__ res = 0.5 * __ieee754_logf (re2 + __real__ x * 2 * a
-					   + im2 + __imag__ x * 2 * b
-					   + ro);
-      __imag__ res = __ieee754_atan2f (__imag__ x + b, __real__ x + a);
-#endif
-
-      /* We have to use the positive branch.  */
-      if (__real__ res < 0.0)
-	res = -res;
     }
 
   return res;
diff --git a/math/s_cacoshl.c b/math/s_cacoshl.c
index 36f7a5f70e..b90b196959 100644
--- a/math/s_cacoshl.c
+++ b/math/s_cacoshl.c
@@ -74,17 +74,13 @@ __cacoshl (__complex__ long double x)
 
       y = __csqrtl (y);
 
-      if (__real__ x < 0.0)
+      if (signbit (__real__ x))
 	y = -y;
 
       __real__ y += __real__ x;
       __imag__ y += __imag__ x;
 
       res = __clogl (y);
-
-      /* We have to use the positive branch.  */
-      if (__real__ res < 0.0)
-	res = -res;
     }
 
   return res;