Print this page
5261 libm should stop using synonyms.h
5298 fabs is 0-sized, confuses dis(1) and others
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Approved by: Gordon Ross <gwr@nexenta.com>


  42  *         [-pi/2 , +pi/2], and let n = k mod 4.
  43  *      2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have
  44  *
  45  *          n        sin(x)      cos(x)        tan(x)
  46  *     ----------------------------------------------------------
  47  *          0          S           C             S/C
  48  *          1          C          -S            -C/S
  49  *          2         -S          -C             S/C
  50  *          3         -C           S            -C/S
  51  *     ----------------------------------------------------------
  52  *
  53  * Special cases:
  54  *      Let trig be any of sin, cos, or tan.
  55  *      trig(+-INF)  is NaN, with signals;
  56  *      trig(NaN)    is that NaN;
  57  *
  58  * Accuracy:
  59  *      computer TRIG(x) returns trig(x) nearly rounded.
  60  */
  61 
  62 #pragma weak sinl = __sinl
  63 
  64 #include "libm.h"
  65 #include "longdouble.h"
  66 
  67 long double
  68 sinl(long double x) {
  69         long double y[2], z = 0.0L;
  70         int n, ix;
  71 
  72         ix = *(int *) &x;           /* High word of x */
  73         ix &= 0x7fffffff;
  74         if (ix <= 0x3ffe9220)                /* |x| ~< pi/4 */
  75                 return (__k_sinl(x, z));
  76         else if (ix >= 0x7fff0000)   /* sin(Inf or NaN) is NaN */
  77                 return (x - x);
  78         else {                          /* argument reduction needed */
  79                 n = __rem_pio2l(x, y);
  80                 switch (n & 3) {
  81                         case 0:
  82                                 return (__k_sinl(y[0], y[1]));


  42  *         [-pi/2 , +pi/2], and let n = k mod 4.
  43  *      2. Let S=S(y1+y2), C=C(y1+y2). Depending on n, we have
  44  *
  45  *          n        sin(x)      cos(x)        tan(x)
  46  *     ----------------------------------------------------------
  47  *          0          S           C             S/C
  48  *          1          C          -S            -C/S
  49  *          2         -S          -C             S/C
  50  *          3         -C           S            -C/S
  51  *     ----------------------------------------------------------
  52  *
  53  * Special cases:
  54  *      Let trig be any of sin, cos, or tan.
  55  *      trig(+-INF)  is NaN, with signals;
  56  *      trig(NaN)    is that NaN;
  57  *
  58  * Accuracy:
  59  *      computer TRIG(x) returns trig(x) nearly rounded.
  60  */
  61 
  62 #pragma weak __sinl = sinl
  63 
  64 #include "libm.h"
  65 #include "longdouble.h"
  66 
  67 long double
  68 sinl(long double x) {
  69         long double y[2], z = 0.0L;
  70         int n, ix;
  71 
  72         ix = *(int *) &x;           /* High word of x */
  73         ix &= 0x7fffffff;
  74         if (ix <= 0x3ffe9220)                /* |x| ~< pi/4 */
  75                 return (__k_sinl(x, z));
  76         else if (ix >= 0x7fff0000)   /* sin(Inf or NaN) is NaN */
  77                 return (x - x);
  78         else {                          /* argument reduction needed */
  79                 n = __rem_pio2l(x, y);
  80                 switch (n & 3) {
  81                         case 0:
  82                                 return (__k_sinl(y[0], y[1]));