Back to index

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

Go to the source code of this file.

Functions

long long int __llround (double x)

Function Documentation

long long int __llround ( double  x)

Definition at line 29 of file s_llround.c.

{
  double xrf;
  long long int xr;
  xr = (long long 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;
}