aboutsummaryrefslogtreecommitdiff
path: root/math/s_ctanl.c
diff options
context:
space:
mode:
Diffstat (limited to 'math/s_ctanl.c')
-rw-r--r--math/s_ctanl.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/math/s_ctanl.c b/math/s_ctanl.c
index 12d700cad9..4fe26119c8 100644
--- a/math/s_ctanl.c
+++ b/math/s_ctanl.c
@@ -83,10 +83,22 @@ __ctanl (__complex__ long double x)
}
else
{
- long double sinhix = __ieee754_sinhl (__imag__ x);
- long double coshix = __ieee754_coshl (__imag__ x);
+ long double sinhix, coshix;
+ if (fabsl (__imag__ x) > LDBL_MIN)
+ {
+ sinhix = __ieee754_sinhl (__imag__ x);
+ coshix = __ieee754_coshl (__imag__ x);
+ }
+ else
+ {
+ sinhix = __imag__ x;
+ coshix = 1.0L;
+ }
- den = cosrx * cosrx + sinhix * sinhix;
+ if (fabsl (sinhix) > fabsl (cosrx) * LDBL_EPSILON)
+ den = cosrx * cosrx + sinhix * sinhix;
+ else
+ den = cosrx * cosrx;
__real__ res = sinrx * cosrx / den;
__imag__ res = sinhix * coshix / den;
}