Back to index

glibc  2.9
Functions
s_trunc.c File Reference
#include <math.h>
#include <math_ldbl_opt.h>

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.

{
  double two52 = copysign (0x1.0p52, x);
  double r, tmp;
  
  __asm (
#ifdef _IEEE_FP_INEXACT
        "addt/suic %2, %3, %1\n\tsubt/suic %1, %3, %0"
#else
        "addt/suc %2, %3, %1\n\tsubt/suc %1, %3, %0"
#endif
        : "=&f"(r), "=&f"(tmp)
        : "f"(x), "f"(two52));

  /* trunc(-0) == -0, and in general we'll always have the same
     sign as our input.  */
  return copysign (r, x);
}

Here is the call graph for this function: