Back to index

glibc  2.9
Defines | Functions | Variables
e_rem_pio2l.c File Reference
#include "math.h"
#include "math_private.h"
#include <ieee754.h>

Go to the source code of this file.

Defines

#define PI_2_1   c[0]
#define PI_2_1t   c[1]

Functions

int32_t __ieee754_rem_pio2l (long double x, long double *y)

Variables

static const int32_t two_over_pi []
static const long double c []

Define Documentation

#define PI_2_1   c[0]
#define PI_2_1t   c[1]

Function Documentation

int32_t __ieee754_rem_pio2l ( long double  x,
long double *  y 
)

Definition at line 198 of file e_rem_pio2l.c.

{
  long double z, w, t;
  double tx[8];
  int exp;
  int64_t n, ix, hx, ixd;
  u_int64_t lx, lxd;

  GET_LDOUBLE_WORDS64 (hx, lx, x);
  ix = hx & 0x7fffffffffffffffLL;
  if (ix <= 0x3fe921fb54442d10LL)  /* x in <-pi/4, pi/4> */
    {
      y[0] = x;
      y[1] = 0;
      return 0;
    }

  if (ix < 0x4002d97c7f3321d0LL)   /* |x| in <pi/4, 3pi/4) */
    {
      if (hx > 0)
       {
         /* 113 + 93 bit PI is ok */
         z = x - PI_2_1;
         y[0] = z - PI_2_1t;
         y[1] = (z - y[0]) - PI_2_1t;
         return 1;
       }
      else
        {
         /* 113 + 93 bit PI is ok */
         z = x + PI_2_1;
         y[0] = z + PI_2_1t;
         y[1] = (z - y[0]) + PI_2_1t;
         return -1;
       }
    }

  if (ix >= 0x7ff0000000000000LL)  /* x is +=oo or NaN */
    {
      y[0] = x - x;
      y[1] = y[0];
      return 0;
    }

  /* Handle large arguments.
     We split the 113 bits of the mantissa into 5 24bit integers
     stored in a double array.  */
  /* Make the IBM extended format 105 bit mantissa look like the ieee854 112
     bit mantissa so the next operatation will give the correct result.  */
  ldbl_extract_mantissa (&ixd, &lxd, &exp, x);
  exp = exp - 23;
  /* This is faster than doing this in floating point, because we
     have to convert it to integers anyway and like this we can keep
     both integer and floating point units busy.  */
  tx [0] = (double)(((ixd >> 25) & 0x7fffff) | 0x800000);
  tx [1] = (double)((ixd >> 1) & 0xffffff);
  tx [2] = (double)(((ixd << 23) | (lxd >> 41)) & 0xffffff);
  tx [3] = (double)((lxd >> 17) & 0xffffff);
  tx [4] = (double)((lxd << 7) & 0xffffff);

  n = __kernel_rem_pio2 (tx, tx + 5, exp, ((lxd << 7) & 0xffffff) ? 5 : 4,
                      3, two_over_pi);

  /* The result is now stored in 3 double values, we need to convert it into
     two long double values.  */
  t = (long double) tx [6] + (long double) tx [7];
  w = (long double) tx [5];

  if (hx >= 0)
    {
      y[0] = w + t;
      y[1] = t - (y[0] - w);
      return n;
    }
  else
    {
      y[0] = -(w + t);
      y[1] = -t - (y[0] + w);
      return -n;
    }
}

Here is the call graph for this function:


Variable Documentation

const long double c[] [static]
Initial value:
 {

#define PI_2_1
 1.57079632679489661923132169155131424e+00L, 


#define PI_2_1t
 8.84372056613570112025531863263659260e-29L, 
}

Definition at line 188 of file e_rem_pio2l.c.

Definition at line 28 of file e_rem_pio2l.c.