floor(3)
NAME
floor, ceil, fabs, rint - floor, ceiling, absolute value, and round-to-
nearest functions
SYNOPSIS
#include <math.h>
double floor(double x)
double ceil(double x)
double fabs(double x)
double rint(double x)
DESCRIPTION
Floor returns the largest integer no greater than x.
Ceil returns the smallest integer no less than x.
Fabs returns the absolute value |x|.
Rint returns the integer (represented as a double precision number)
nearest x in the direction of the prevailing rounding mode.
NOTES
In the default rounding mode, to nearest, rint(x) is the integer nearest
x with the additional stipulation that if |rint(x)-x| = 1/2 then rint(x)
is even. Other rounding modes can make rint act like floor, or like
ceil, or round towards zero.
Another way to obtain an integer near x is to declare (in C)
double x; int k; k = x;
Most C compilers round x towards 0 to get the integer k, but some do
otherwise. If in doubt, use floor, ceil, or rint first, whichever you
intend. Also note that, if x is larger than k can accommodate, the value
of k and the presence or absence of an integer overflow are hard to
predict.
SEE ALSO
abs(3), ieee(3), math(3).