NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | NOTES | ATTRIBUTES | SEE ALSO
$(NUCLEUS_DIR)/lib/libm.a #include <math.h>double rint(double x);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
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, rintx() is the integer closest to x, with the additional stipulation that if:
|rint(x)-x|=1/2
Then rintx() 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.
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 | API RESTRICTIONS | DESCRIPTION | NOTES | ATTRIBUTES | SEE ALSO