about summary refs log tree commit diff
path: root/sysdeps/libm-ieee754/s_csinhf.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-ieee754/s_csinhf.c')
-rw-r--r--sysdeps/libm-ieee754/s_csinhf.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/sysdeps/libm-ieee754/s_csinhf.c b/sysdeps/libm-ieee754/s_csinhf.c
index 204bbfebb9..93f83cf7b6 100644
--- a/sysdeps/libm-ieee754/s_csinhf.c
+++ b/sysdeps/libm-ieee754/s_csinhf.c
@@ -21,34 +21,38 @@
 #include <complex.h>
 #include <math.h>
 
+#include "math_private.h"
+
 
 __complex__ float
 __csinhf (__complex__ float x)
 {
   __complex__ float retval;
   int negate = signbit (__real__ x);
+  int rcls = fpclassify (__real__ x);
+  int icls = fpclassify (__imag__ x);
 
   __real__ x = fabsf (__real__ x);
 
-  if (isfinite (__real__ x))
+  if (rcls >= FP_ZERO)
     {
-      if (isfinite (__imag__ x))
+      /* Real part is finite.  */
+      if (icls >= FP_ZERO)
 	{
-	  float exp_val = __expf (__real__ x);
-	  float rec_exp_val = 1.0 / exp_val;
+	  /* Imaginary part is finite.  */
+	   float sinh_val = __ieee754_sinhf (__real__ x);
 
-	  __real__ retval = (0.5 * (exp_val - rec_exp_val)
-			     * __cosf (__imag__ x));
-	  __imag__ retval = (0.5 * (exp_val - rec_exp_val)
-			     * __sinf (__imag__ x));
+	  __real__ retval = sinh_val * __cosf (__imag__ x);
+	  __imag__ retval = sinh_val * __sinf (__imag__ x);
 
 	  if (negate)
 	    __real__ retval = -__real__ retval;
 	}
       else
 	{
-	  if (__real__ x == 0)
+	  if (rcls == FP_ZERO)
 	    {
+	      /* Real part is 0.0.  */
 	      __real__ retval = __copysignf (0.0, negate ? -1.0 : 1.0);
 	      __imag__ retval = __nanf ("") + __nanf ("");
 	    }
@@ -59,15 +63,18 @@ __csinhf (__complex__ float x)
 	    }
 	}
     }
-  else if (__isinff (__real__ x))
+  else if (rcls == FP_INFINITE)
     {
-      if (__imag__ x == 0.0)
+      /* Real part is infinite.  */
+      if (icls == FP_ZERO)
 	{
+	  /* Imaginary part is 0.0.  */
 	  __real__ retval = negate ? -HUGE_VALF : HUGE_VALF;
 	  __imag__ retval = __imag__ x;
 	}
-      else if (isfinite (__imag__ x))
+      else if (icls > FP_ZERO)
 	{
+	  /* Imaginary part is finite.  */
 	  __real__ retval = __copysignf (HUGE_VALF, __cosf (__imag__ x));
 	  __imag__ retval = __copysignf (HUGE_VALF, __sinf (__imag__ x));
 
@@ -83,16 +90,8 @@ __csinhf (__complex__ float x)
     }
   else
     {
-      if (__imag__ x == 0.0)
-	{
-	  __real__ retval = __nanf ("");
-	  __imag__ retval = __imag__ x;
-	}
-      else
-	{
-	  __real__ retval = __nanf ("");
-	  __imag__ retval = __nanf ("");
-	}
+      __real__ retval = __nanf ("");
+      __imag__ retval = __imag__ x == 0.0 ? __imag__ x : __nanf ("");
     }
 
   return retval;