NAME | SYNOPSIS | DESCRIPTION | NOTES | ATTRIBUTES | SEE ALSO
#include <math.h>double rint(double x);
The rint function finds the integer (represented as a double precision number) nearest to x in the direction of the prevailing rounding mode.
In the default rounding mode on a machine that conforms to IEEE 754, rint(x) is the integer closest to x, with the additional stipulation that if |rint(x)-x|=1/2, then rint(x) will be even. Other rounding modes can make rint perform like floor, or like ceil, or round up to 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 up to 0 to get the integer k, but not all. Use floor, ceil, or rint first, depending on the result required. Note that if x is larger than k can accommodate, the value of k and the presence or absence of an integer overflow are unpredictable.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | DESCRIPTION | NOTES | ATTRIBUTES | SEE ALSO