RINT(3) BSD Programmer's Manual RINT(3) NNAAMMEE rriinntt - and round-to-closest integer functions SSYYNNOOPPSSIISS ##iinncclluuddee <<mmaatthh..hh>> _d_o_u_b_l_e rriinntt(_d_o_u_b_l_e _x); DDEESSCCRRIIPPTTIIOONN The rriinntt() function finds the integer (represented as a double precision number) nearest to _x in the direction of the prevailing rounding mode. NNOOTTEESS On a VAX, rriinntt(_x) is equivalent to adding half to the magnitude and then rounding towards zero. In the default rounding mode, to nearest, on a machine that conforms to IEEE 754, rriinntt(_x) is the integer nearest _x with the additional stipula- tion that if |rint(x)-x|=1/2 then rriinntt(_x) is even. Other rounding modes can make rriinntt() act like fflloooorr(), or like cceeiill(), 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 oth- erwise. If in doubt, use fflloooorr(), cceeiill(), or rriinntt() 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 pre- dict. SSEEEE AALLSSOO abs(3), fabs(3), ceil(3), floor(3), ieee(3), math(3) HHIISSTTOORRYY A rriinntt() function appeared in Version 6 AT&T UNIX. 4.4BSD June 4, 1993 1