Back to index

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

Go to the source code of this file.

Functions

float __roundf (float x)

Variables

static const float huge = 1.0e30

Function Documentation

float __roundf ( float  x)

Definition at line 30 of file s_roundf.c.

{
  int32_t i0, j0;

  GET_FLOAT_WORD (i0, x);
  j0 = ((i0 >> 23) & 0xff) - 0x7f;
  if (j0 < 23)
    {
      if (j0 < 0)
       {
         if (huge + x > 0.0F)
           {
             i0 &= 0x80000000;
             if (j0 == -1)
              i0 |= 0x3f800000;
           }
       }
      else
       {
         u_int32_t i = 0x007fffff >> j0;
         if ((i0 & i) == 0)
           /* X is integral.  */
           return x;
         if (huge + x > 0.0F)
           {
             /* Raise inexact if x != 0.  */
             i0 += 0x00400000 >> j0;
             i0 &= ~i;
           }
       }
    }
  else
    {
      if (j0 == 0x80)
       /* Inf or NaN.  */
       return x + x;
      else
       return x;
    }

  SET_FLOAT_WORD (x, i0);
  return x;
}

Here is the call graph for this function:


Variable Documentation

const float huge = 1.0e30 [static]

Definition at line 26 of file s_roundf.c.