X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fcosl.c;h=0794d28474c46b1fd382fd1f1bbd6fda6afdb276;hb=9448b0513e2eec020fbca9c10412b83df5027a16;hp=2c650cdce4fb5e46da881a154652c1303c7cb921;hpb=b69f695acedd4ce2798ef9ea28d834ceccc789bd;p=musl diff --git a/src/math/cosl.c b/src/math/cosl.c index 2c650cdc..0794d284 100644 --- a/src/math/cosl.c +++ b/src/math/cosl.c @@ -36,35 +36,33 @@ long double cosl(long double x) { return cos(x); } #elif (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384 -#include "__rem_pio2l.h" - 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;