Back to index

glibc  2.9
Functions | Variables
s_remquol.c File Reference
#include <math.h>
#include "math_private.h"
#include <math_ldbl_opt.h>

Go to the source code of this file.

Functions

long double __remquol (long double x, long double y, int *quo)
 long_double_symbol (libm, __remquol, remquol)

Variables

static const long double zero = 0.0

Function Documentation

long double __remquol ( long double  x,
long double  y,
int quo 
)

Definition at line 32 of file s_remquol.c.

{
  int64_t hx,hy;
  u_int64_t sx,lx,ly,qs;
  int cquo;

  GET_LDOUBLE_WORDS64 (hx, lx, x);
  GET_LDOUBLE_WORDS64 (hy, ly, y);
  sx = hx & 0x8000000000000000ULL;
  qs = sx ^ (hy & 0x8000000000000000ULL);
  hy &= 0x7fffffffffffffffLL;
  hx &= 0x7fffffffffffffffLL;

  /* Purge off exception values.  */
  if ((hy | (ly & 0x7fffffffffffffff)) == 0)
    return (x * y) / (x * y);                    /* y = 0 */
  if ((hx >= 0x7ff0000000000000LL)        /* x not finite */
      || ((hy >= 0x7ff0000000000000LL)           /* y is NaN */
         && (((hy - 0x7ff0000000000000LL) | ly) != 0)))
    return (x * y) / (x * y);

  if (hy <= 0x7fbfffffffffffffLL)
    x = __ieee754_fmodl (x, 8 * y);              /* now x < 8y */

  if (((hx - hy) | (lx - ly)) == 0)
    {
      *quo = qs ? -1 : 1;
      return zero * x;
    }

  x  = fabsl (x);
  y  = fabsl (y);
  cquo = 0;

  if (x >= 4 * y)
    {
      x -= 4 * y;
      cquo += 4;
    }
  if (x >= 2 * y)
    {
      x -= 2 * y;
      cquo += 2;
    }

  if (hy < 0x0020000000000000LL)
    {
      if (x + x > y)
       {
         x -= y;
         ++cquo;
         if (x + x >= y)
           {
             x -= y;
             ++cquo;
           }
       }
    }
  else
    {
      long double y_half = 0.5L * y;
      if (x > y_half)
       {
         x -= y;
         ++cquo;
         if (x >= y_half)
           {
             x -= y;
             ++cquo;
           }
       }
    }

  *quo = qs ? -cquo : cquo;

  if (sx)
    x = -x;
  return x;
}

Here is the call graph for this function:

long_double_symbol ( libm  ,
__remquol  ,
remquol   
)

Variable Documentation

const long double zero = 0.0 [static]

Definition at line 28 of file s_remquol.c.