math: tan cleanups

* use unsigned arithmetics on the representation
* store arg reduction quotient in unsigned (so n%2 would work like n&1)
* use different convention to pass the arg reduction bit to __tan
  (this argument used to be 1 for even and -1 for odd reduction
  which meant obscure bithacks, the new n&1 is cleaner)
* raise inexact and underflow flags correctly for small x
  (tanl(x) may still raise spurious underflow for small but normal x)
  (this exception raising code increases codesize a bit, similar fixes
  are needed in many other places, it may worth investigating at some
  point if the inexact and underflow flags are worth raising correctly
  as this is not strictly required by the standard)
* tanf manual reduction optimization is kept for now
* tanl code path is cleaned up to follow similar logic to tan and tanf
This commit is contained in:
Szabolcs Nagy
2013-05-18 12:34:00 +00:00
parent 22730d6560
commit 1d5ba3bb5a
6 changed files with 80 additions and 106 deletions

View File

@ -25,7 +25,7 @@ static const double T[] = {
0x1362b9bf971bcd.0p-59, /* 0.00946564784943673166728 */
};
float __tandf(double x, int iy)
float __tandf(double x, int odd)
{
double_t z,r,w,s,t,u;
@ -50,6 +50,5 @@ float __tandf(double x, int iy)
s = z*x;
u = T[0] + z*T[1];
r = (x + s*u) + (s*w)*(t + w*r);
if(iy==1) return r;
else return -1.0/r;
return odd ? -1.0/r : r;
}