aboutsummaryrefslogtreecommitdiff
path: root/math/s_ctanf.c
diff options
context:
space:
mode:
Diffstat (limited to 'math/s_ctanf.c')
-rw-r--r--math/s_ctanf.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/math/s_ctanf.c b/math/s_ctanf.c
index 4cba559a44..2559f83f84 100644
--- a/math/s_ctanf.c
+++ b/math/s_ctanf.c
@@ -83,10 +83,22 @@ __ctanf (__complex__ float x)
}
else
{
- float sinhix = __ieee754_sinhf (__imag__ x);
- float coshix = __ieee754_coshf (__imag__ x);
+ float sinhix, coshix;
+ if (fabsf (__imag__ x) > FLT_MIN)
+ {
+ sinhix = __ieee754_sinhf (__imag__ x);
+ coshix = __ieee754_coshf (__imag__ x);
+ }
+ else
+ {
+ sinhix = __imag__ x;
+ coshix = 1.0f;
+ }
- den = cosrx * cosrx + sinhix * sinhix;
+ if (fabsf (sinhix) > fabsf (cosrx) * FLT_EPSILON)
+ den = cosrx * cosrx + sinhix * sinhix;
+ else
+ den = cosrx * cosrx;
__real__ res = sinrx * cosrx / den;
__imag__ res = sinhix * coshix / den;
}