Back to index

glibc  2.9
Functions
s_trunc.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

double __trunc (double x)

Function Documentation

double __trunc ( double  x)

Definition at line 27 of file s_trunc.c.

{
  int32_t i0, j0;
  u_int32_t i1;
  int sx;

  EXTRACT_WORDS (i0, i1, x);
  sx = i0 & 0x80000000;
  j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
  if (j0 < 20)
    {
      if (j0 < 0)
       /* The magnitude of the number is < 1 so the result is +-0.  */
       INSERT_WORDS (x, sx, 0);
      else
       INSERT_WORDS (x, sx | (i0 & ~(0x000fffff >> j0)), 0);
    }
  else if (j0 > 51)
    {
      if (j0 == 0x400)
       /* x is inf or NaN.  */
       return x + x;
    }
  else
    {
      INSERT_WORDS (x, i0, i1 & ~(0xffffffffu >> (j0 - 20)));
    }

  return x;
}

Here is the call graph for this function: