Back to index

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

Go to the source code of this file.

Functions

unsigned int __uitrunc (double x)

Function Documentation

unsigned int __uitrunc ( double  x)

Definition at line 26 of file uitrunc.c.

{
  double xrf;
  unsigned int xr;
  xr = (unsigned int) x;
  xrf = (double) xr;
  if (x >= 0.0)
    if (x - xrf >= 0.5 && x - xrf < 1.0 && x + 1 > 0)
      return x + 1;
    else
      return x;
  else
    if (xrf - x >= 0.5 && xrf - x < 1.0 && x - 1 < 0)
      return x - 1;
    else
      return x;
}