Back to index

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

Go to the source code of this file.

Functions

long long int __llrintf (float x)

Variables

static const float two23 [2]

Function Documentation

long long int __llrintf ( float  x)

Definition at line 34 of file s_llrintf.c.

{
  int32_t j0;
  u_int32_t i0;
  volatile float w;
  float t;
  long long int result;
  int sx;

  GET_FLOAT_WORD (i0, x);

  sx = i0 >> 31;
  j0 = ((i0 >> 23) & 0xff) - 0x7f;
  i0 &= 0x7fffff;
  i0 |= 0x800000;

  if (j0 < (int32_t) (sizeof (long long int) * 8) - 1)
    {
      if (j0 >= 23)
       result = (long long int) i0 << (j0 - 23);
      else
       {
         w = two23[sx] + x;
         t = w - two23[sx];
         GET_FLOAT_WORD (i0, t);
         j0 = ((i0 >> 23) & 0xff) - 0x7f;
         i0 &= 0x7fffff;
         i0 |= 0x800000;

         result = (j0 < 0 ? 0 : i0 >> (23 - 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 float two23[2] [static]
Initial value:
{
  8.3886080000e+06, 
 -8.3886080000e+06, 
}

Definition at line 26 of file s_llrintf.c.