From 6d85096f49fa955e7e1473b7deb30ce55b6c8be0 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Thu, 15 Aug 2013 14:05:19 +0000 Subject: math: clean up atan2.c * remove volatile hacks * don't care about inexact flag for now (removed all the +-tiny) * fix atanl to raise underflow properly * remove signed int arithmetics * use pi/2 instead of pi_o_2 (gcc generates the same code, which is not correct, but it does not matter: we mainly care about nearest rounding) --- src/math/atanl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/math/atanl.c') diff --git a/src/math/atanl.c b/src/math/atanl.c index e76693e4..d29e6316 100644 --- a/src/math/atanl.c +++ b/src/math/atanl.c @@ -70,8 +70,8 @@ long double atanl(long double x) union IEEEl2bits u; long double w,s1,s2,z; int id; - int16_t expsign, expt; - int32_t expman; + uint16_t expsign, expt; + uint32_t expman; u.e = x; expsign = u.xbits.expsign; @@ -81,15 +81,16 @@ long double atanl(long double x) ((u.bits.manh&~LDBL_NBIT)|u.bits.manl)!=0) /* NaN */ return x+x; z = atanhi[3] + 0x1p-120f; - return expsign < 0 ? -z : z; + return expsign>>15 ? -z : z; } /* Extract the exponent and the first few bits of the mantissa. */ /* XXX There should be a more convenient way to do this. */ expman = (expt << 8) | ((u.bits.manh >> (LDBL_MANH_SIZE - 9)) & 0xff); if (expman < ((0x3fff - 2) << 8) + 0xc0) { /* |x| < 0.4375 */ if (expt < 0x3fff - 32) { /* if |x| is small, atanl(x)~=x */ - /* raise inexact if x!=0 */ - FORCE_EVAL(x + 0x1p120f); + /* raise underflow if subnormal */ + if (expt == 0) + FORCE_EVAL((float)x); return x; } id = -1; @@ -122,6 +123,6 @@ long double atanl(long double x) if (id < 0) return x - x*(s1+s2); z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x); - return expsign < 0 ? -z : z; + return expsign>>15 ? -z : z; } #endif -- cgit 1.4.1