Back to index

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

Go to the source code of this file.

Functions

long long int __llrintl (long double x)

Variables

static const long double two63 [2]

Function Documentation

long long int __llrintl ( long double  x)

Definition at line 34 of file s_llrintl.c.

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

  GET_LDOUBLE_WORDS (se, i0, i1, x);

  sx = (se >> 15) & 1;
  j0 = (se & 0x7fff) - 0x3fff;

  if (j0 < (int32_t) (8 * sizeof (long long int)) - 1)
    {
      if (j0 >= 63)
       result = (((long long int) i0 << 32) | i1) << (j0 - 63);
      else
       {
         w = two63[sx] + x;
         t = w - two63[sx];
         GET_LDOUBLE_WORDS (se, i0, i1, t);
         j0 = (se & 0x7fff) - 0x3fff;

         if (j0 < 0)
           result = 0;
         else if (j0 <= 31)
           result = i0 >> (31 - j0);
         else
           result = ((long long int) i0 << (j0 - 31)) | (i1 >> (63 - 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 two63[2] [static]
Initial value:
{
  9.223372036854775808000000e+18, 
 -9.223372036854775808000000e+18  
}

Definition at line 26 of file s_llrintl.c.