rint(3M)
NAME
rint() − round-to-nearest function
SYNOPSIS
#include <math.h>
double rint(double x);
DESCRIPTION
rint() returns the integer (represented as a double precision number) nearest x in the direction of the current rounding mode.
In the default rounding mode (round 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.
If the current rounding mode rounds toward negative infinity, rint() is identical to floor(). If the current rounding mode rounds toward positive infinity, rint() is identical to ceil().
Another way to obtain an integer near x is to declare (in C):
double x; int k; k = x;
The HP C compiler rounds x toward 0 to get the integer k. 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.
To use this function, link in the math library by specifying −lm on the compiler or linker command line.
RETURN VALUE
If x is ±INFINITY, the rint() function returns ±INFINITY respectively.
If x is NaN, the rint() function returns NaN.
ERRORS
No errors are defined.
SEE ALSO
floor(3M), ceil(3M), fmod(3M), fabs(3M), fpgetround(3M), isinf(3M), isnan(3M).
STANDARDS CONFORMANCE
rint(): XPG4.2
Hewlett-Packard Company — HP-UX Release 10.20: July 1996