Print this page




  55  * Special cases:
  56  *      Let trig be any of sin, cos, or tan.
  57  *      trig(+-INF)  is NaN, with signals;
  58  *      trig(NaN)    is that NaN;
  59  *
  60  * Accuracy:
  61  *      computer TRIG(x) returns trig(x) nearly rounded.
  62  */
  63 /* INDENT ON */
  64 
  65 #include "libm.h"
  66 #include "libm_synonyms.h"
  67 #include "longdouble.h"
  68 
  69 #include <sys/isa_defs.h>
  70 
  71 long double
  72 sinl(long double x) {
  73         long double y[2], z = 0.0L;
  74         int n, ix;
  75 #if defined(_LITTLE_ENDIAN)
  76         int *px = (int *) &x;
  77 #endif
  78 
  79         /* sin(Inf or NaN) is NaN */
  80         if (!finitel(x))
  81                 return x - x;
  82 
  83         /* High word of x. */
  84 #if defined(_BIG_ENDIAN)
  85         ix = *(int *) &x;
  86 #else
  87         XTOI(px, ix);


  88 #endif
  89         /* |x| ~< pi/4 */
  90         ix &= 0x7fffffff;
  91         if (ix <= 0x3ffe9220) {
  92                 return __k_sinl(x, z);
  93         }
  94 
  95         /* argument reduction needed */
  96         else {
  97                 n = __rem_pio2l(x, y);
  98                 switch (n & 3) {
  99                 case 0:
 100                         return __k_sinl(y[0], y[1]);
 101                 case 1:
 102                         return __k_cosl(y[0], y[1]);
 103                 case 2:
 104                         return -__k_sinl(y[0], y[1]);
 105                 case 3:
 106                         return -__k_cosl(y[0], y[1]);
 107                 /* NOTREACHED */
 108                 }
 109         }
 110     return 0.0L;
 111 }


  55  * Special cases:
  56  *      Let trig be any of sin, cos, or tan.
  57  *      trig(+-INF)  is NaN, with signals;
  58  *      trig(NaN)    is that NaN;
  59  *
  60  * Accuracy:
  61  *      computer TRIG(x) returns trig(x) nearly rounded.
  62  */
  63 /* INDENT ON */
  64 
  65 #include "libm.h"
  66 #include "libm_synonyms.h"
  67 #include "longdouble.h"
  68 
  69 #include <sys/isa_defs.h>
  70 
  71 long double
  72 sinl(long double x) {
  73         long double y[2], z = 0.0L;
  74         int n, ix;
  75 #if defined(__i386) || defined(__amd64)
  76         int *px = (int *) &x;
  77 #endif
  78 
  79         /* sin(Inf or NaN) is NaN */
  80         if (!finitel(x))
  81                 return x - x;
  82 
  83         /* High word of x. */
  84 #if defined(__i386) || defined(__amd64)


  85         XTOI(px, ix);
  86 #else
  87         ix = *(int *) &x;
  88 #endif
  89         /* |x| ~< pi/4 */
  90         ix &= 0x7fffffff;
  91         if (ix <= 0x3ffe9220)
  92                 return __k_sinl(x, z);

  93 
  94         /* argument reduction needed */
  95         else {
  96                 n = __rem_pio2l(x, y);
  97                 switch (n & 3) {
  98                 case 0:
  99                         return __k_sinl(y[0], y[1]);
 100                 case 1:
 101                         return __k_cosl(y[0], y[1]);
 102                 case 2:
 103                         return -__k_sinl(y[0], y[1]);
 104                 case 3:
 105                         return -__k_cosl(y[0], y[1]);
 106                 /* NOTREACHED */
 107                 }
 108         }
 109         return 0.0L;
 110 }