diff options
author | Rich Felker <dalias@aerifal.cx> | 2013-05-18 12:06:42 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2013-05-18 12:06:42 -0400 |
commit | 83af1dd65a11f3da3f99ba861248a841c402ccaa (patch) | |
tree | dece0960d64fb52abcf7a8195bf5082523cea70b /src/math/cosl.c | |
parent | 69ee9b2cb169ee843ac9e209f919d088499152f7 (diff) | |
parent | bfda37935867f9bf271d6074db0accf05c63ad10 (diff) | |
download | musl-83af1dd65a11f3da3f99ba861248a841c402ccaa.tar.gz musl-83af1dd65a11f3da3f99ba861248a841c402ccaa.tar.bz2 musl-83af1dd65a11f3da3f99ba861248a841c402ccaa.tar.xz musl-83af1dd65a11f3da3f99ba861248a841c402ccaa.zip |
Merge remote-tracking branch 'nsz/review'
Diffstat (limited to 'src/math/cosl.c')
-rw-r--r-- | src/math/cosl.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/math/cosl.c b/src/math/cosl.c index 25d9005a..0794d284 100644 --- a/src/math/cosl.c +++ b/src/math/cosl.c @@ -39,30 +39,30 @@ long double cosl(long double x) { long double cosl(long double x) { union IEEEl2bits z; - int e0; + unsigned n; long double y[2]; long double hi, lo; z.e = x; z.bits.sign = 0; - /* If x = +-0 or x is a subnormal number, then cos(x) = 1 */ - if (z.bits.exp == 0) - return 1.0; - /* If x = NaN or Inf, then cos(x) = NaN. */ - if (z.bits.exp == 32767) + if (z.bits.exp == 0x7fff) return (x - x) / (x - x); - /* Optimize the case where x is already within range. */ - if (z.e < M_PI_4) + /* |x| < (double)pi/4 */ + if (z.e < M_PI_4) { + /* |x| < 0x1p-64 */ + if (z.bits.exp < 0x3fff - 64) + /* raise inexact if x!=0 */ + return 1.0 + x; return __cosl(z.e, 0); + } - e0 = __rem_pio2l(x, y); + n = __rem_pio2l(x, y); hi = y[0]; lo = y[1]; - - switch (e0 & 3) { + switch (n & 3) { case 0: hi = __cosl(hi, lo); break; |