Back to index

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

Go to the source code of this file.

Functions

float __roundf (float x)

Function Documentation

float __roundf ( float  x)

Definition at line 24 of file s_roundf.c.

{
  const float almost_half = 0x1.fffffep-2;
  const float two23 = 0x1.0p23;
  float r, tmp;
  
  __asm (
#ifdef _IEEE_FP_INEXACT
        "adds/suic %2, %3, %1\n\tsubs/suic %1, %3, %0"
#else
        "adds/suc %2, %3, %1\n\tsubs/suc %1, %3, %0"
#endif
        : "=&f"(r), "=&f"(tmp)
        : "f"(fabsf (x) + almost_half), "f"(two23));

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

Here is the call graph for this function: