src/libm/k_sin.c
changeset 11683 48bcba563d9c
parent 6044 35448a5ea044
     1.1 --- a/src/libm/k_sin.c	Sat Nov 04 15:34:14 2017 -0700
     1.2 +++ b/src/libm/k_sin.c	Sat Nov 04 15:53:19 2017 -0700
     1.3 @@ -1,4 +1,3 @@
     1.4 -/* @(#)k_sin.c 5.1 93/09/24 */
     1.5  /*
     1.6   * ====================================================
     1.7   * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
     1.8 @@ -10,11 +9,6 @@
     1.9   * ====================================================
    1.10   */
    1.11  
    1.12 -#if defined(LIBM_SCCS) && !defined(lint)
    1.13 -static const char rcsid[] =
    1.14 -    "$NetBSD: k_sin.c,v 1.8 1995/05/10 20:46:31 jtc Exp $";
    1.15 -#endif
    1.16 -
    1.17  /* __kernel_sin( x, y, iy)
    1.18   * kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854
    1.19   * Input x is assumed to be bounded by ~pi/4 in magnitude.
    1.20 @@ -46,42 +40,26 @@
    1.21  #include "math_libm.h"
    1.22  #include "math_private.h"
    1.23  
    1.24 -#ifdef __STDC__
    1.25  static const double
    1.26 -#else
    1.27 -static double
    1.28 -#endif
    1.29 -  half = 5.00000000000000000000e-01,    /* 0x3FE00000, 0x00000000 */
    1.30 -    S1 = -1.66666666666666324348e-01,   /* 0xBFC55555, 0x55555549 */
    1.31 -    S2 = 8.33333333332248946124e-03,    /* 0x3F811111, 0x1110F8A6 */
    1.32 -    S3 = -1.98412698298579493134e-04,   /* 0xBF2A01A0, 0x19C161D5 */
    1.33 -    S4 = 2.75573137070700676789e-06,    /* 0x3EC71DE3, 0x57B1FE7D */
    1.34 -    S5 = -2.50507602534068634195e-08,   /* 0xBE5AE5E6, 0x8A2B9CEB */
    1.35 -    S6 = 1.58969099521155010221e-10;    /* 0x3DE5D93A, 0x5ACFD57C */
    1.36 +half =  5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
    1.37 +S1  = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
    1.38 +S2  =  8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
    1.39 +S3  = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
    1.40 +S4  =  2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
    1.41 +S5  = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
    1.42 +S6  =  1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
    1.43  
    1.44 -#ifdef __STDC__
    1.45 -double attribute_hidden
    1.46 -__kernel_sin(double x, double y, int iy)
    1.47 -#else
    1.48 -double attribute_hidden
    1.49 -__kernel_sin(x, y, iy)
    1.50 -     double x, y;
    1.51 -     int iy;                    /* iy=0 if y is zero */
    1.52 -#endif
    1.53 +double attribute_hidden __kernel_sin(double x, double y, int iy)
    1.54  {
    1.55 -    double z, r, v;
    1.56 -    int32_t ix;
    1.57 -    GET_HIGH_WORD(ix, x);
    1.58 -    ix &= 0x7fffffff;           /* high word of x */
    1.59 -    if (ix < 0x3e400000) {      /* |x| < 2**-27 */
    1.60 -        if ((int) x == 0)
    1.61 -            return x;
    1.62 -    }                           /* generate inexact */
    1.63 -    z = x * x;
    1.64 -    v = z * x;
    1.65 -    r = S2 + z * (S3 + z * (S4 + z * (S5 + z * S6)));
    1.66 -    if (iy == 0)
    1.67 -        return x + v * (S1 + z * r);
    1.68 -    else
    1.69 -        return x - ((z * (half * y - v * r) - y) - v * S1);
    1.70 +	double z,r,v;
    1.71 +	int32_t ix;
    1.72 +	GET_HIGH_WORD(ix,x);
    1.73 +	ix &= 0x7fffffff;			/* high word of x */
    1.74 +	if(ix<0x3e400000)			/* |x| < 2**-27 */
    1.75 +	   {if((int)x==0) return x;}		/* generate inexact */
    1.76 +	z	=  x*x;
    1.77 +	v	=  z*x;
    1.78 +	r	=  S2+z*(S3+z*(S4+z*(S5+z*S6)));
    1.79 +	if(iy==0) return x+v*(S1+z*r);
    1.80 +	else      return x-((z*(half*y-v*r)-y)-v*S1);
    1.81  }