Back to index

glibc  2.9
Functions | Variables
s_llrintl.c File Reference
#include <math.h>
#include "math_private.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

long long int __llrintl (long double x)

Variables

static const long double two112 [2]

Function Documentation

long long int __llrintl ( long double  x)

Definition at line 34 of file s_llrintl.c.

{
  int32_t j0;
  u_int64_t i0,i1;
  volatile long double w;
  long double t;
  long long int result;
  int sx;

  GET_LDOUBLE_WORDS64 (i0, i1, x);
  j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
  sx = i0 >> 63;
  i0 &= 0x0000ffffffffffffLL;
  i0 |= 0x0001000000000000LL;

  if (j0 < (int32_t) (8 * sizeof (long long int)) - 1)
    {
      w = two112[sx] + x;
      t = w - two112[sx];
      GET_LDOUBLE_WORDS64 (i0, i1, t);
      j0 = ((i0 >> 48) & 0x7fff) - 0x3fff;
      i0 &= 0x0000ffffffffffffLL;
      i0 |= 0x0001000000000000LL;

      if (j0 < 0)
       result = 0;
      else if (j0 <= 48)
       result = i0 >> (48 - j0);
      else
       result = ((long long int) i0 << (j0 - 48)) | (i1 >> (112 - j0));
    }
  else
    {
      /* The number is too large.  It is left implementation defined
        what happens.  */
      return (long long int) x;
    }

  return sx ? -result : result;
}

Here is the call graph for this function:


Variable Documentation

const long double two112[2] [static]
Initial value:
{
  5.19229685853482762853049632922009600E+33L, 
 -5.19229685853482762853049632922009600E+33L  
}

Definition at line 27 of file s_llrintl.c.