diff options
author | Szabolcs Nagy <nsz@port70.net> | 2013-08-15 14:05:19 +0000 |
---|---|---|
committer | Szabolcs Nagy <nsz@port70.net> | 2013-08-15 14:05:19 +0000 |
commit | 6d85096f49fa955e7e1473b7deb30ce55b6c8be0 (patch) | |
tree | a4254fb4660ce953cdbc2b956a0e6d8fd54d312e /src/math/atanl.c | |
parent | 31c5fb80b9eae86f801be4f46025bc6532a554c5 (diff) | |
download | musl-6d85096f49fa955e7e1473b7deb30ce55b6c8be0.tar.gz musl-6d85096f49fa955e7e1473b7deb30ce55b6c8be0.tar.bz2 musl-6d85096f49fa955e7e1473b7deb30ce55b6c8be0.tar.xz musl-6d85096f49fa955e7e1473b7deb30ce55b6c8be0.zip |
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)
Diffstat (limited to 'src/math/atanl.c')
-rw-r--r-- | src/math/atanl.c | 13 |
1 files changed, 7 insertions, 6 deletions
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 |