From bfda37935867f9bf271d6074db0accf05c63ad10 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sat, 18 May 2013 14:40:22 +0000 Subject: math: sin cos cleanup * use unsigned arithmetics * use unsigned to store arg reduction quotient (so n&3 is understood) * remove z=0.0 variables, use literal 0 * raise underflow and inexact exceptions properly when x is small * fix spurious underflow in tanl --- src/math/tanl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/math/tanl.c') diff --git a/src/math/tanl.c b/src/math/tanl.c index 3b51e011..546c7a02 100644 --- a/src/math/tanl.c +++ b/src/math/tanl.c @@ -53,11 +53,12 @@ long double tanl(long double x) /* |x| < (double)pi/4 */ if (z.e < M_PI_4) { - /* x = +-0 or x is subnormal */ - if (z.bits.exp == 0) - /* inexact and underflow if x!=0 */ - return x + x*0x1p-120f; - /* can raise spurious underflow */ + /* |x| < 0x1p-64 */ + if (z.bits.exp < 0x3fff - 64) { + /* raise inexact if x!=0 and underflow if subnormal */ + FORCE_EVAL(z.bits.exp == 0 ? x/0x1p120f : x+0x1p120f); + return x; + } return __tanl(x, 0, 0); } -- cgit v1.2.1