RINT(3) BSD Programmer's Manual RINT(3)
r
\bri
\bin
\bnt
\bt - and round-to-closest integer functions
S
\bSY
\bYN
\bNO
\bOP
\bPS
\bSI
\bIS
\bS
#
\b#i
\bin
\bnc
\bcl
\blu
\bud
\bde
\be <
\b<m
\bma
\bat
\bth
\bh.
\b.h
\bh>
\b>
r
\bri
\bin
\bnt
\bt(_
\bd_
\bo_
\bu_
\bb_
\bl_
\be _
\bx);
D
\bDE
\bES
\bSC
\bCR
\bRI
\bIP
\bPT
\bTI
\bIO
\bON
\bN
The r
\bri
\bin
\bnt
\bt() function finds the integer (represented as a double precision
number) nearest to _
\bx in the direction of the prevailing rounding mode.
On a VAX, r
\bri
\bin
\bnt
\bt(_
\bx) is equivalent to adding half to the magnitude and then
In the default rounding mode, to nearest, on a machine that conforms to
IEEE 754, r
\bri
\bin
\bnt
\bt(_
\bx) is the integer nearest _
\bx with the additional stipula-
tion that if |rint(x)-x|=1/2 then r
\bri
\bin
\bnt
\bt(_
\bx) is even. Other rounding modes
can make r
\bri
\bin
\bnt
\bt() act like f
\bfl
\blo
\boo
\bor
\br(), or like c
\bce
\bei
\bil
\bl(), or round towards zero.
Another way to obtain an integer near _
\bx is to declare (in C)
Most C compilers round _
\bx towards 0 to get the integer _
\bk, but some do oth-
erwise. If in doubt, use f
\bfl
\blo
\boo
\bor
\br(), c
\bce
\bei
\bil
\bl(), or r
\bri
\bin
\bnt
\bt() first, whichever you
intend. Also note that, if x is larger than _
\bk can accommodate, the value
of _
\bk and the presence or absence of an integer overflow are hard to pre-
S
\bSE
\bEE
\bE A
\bAL
\bLS
\bSO
\bO
abs(3), fabs(3), ceil(3), floor(3), ieee(3), math(3)
H
\bHI
\bIS
\bST
\bTO
\bOR
\bRY
\bY
A r
\bri
\bin
\bnt
\bt() function appeared in Version 6 AT&T UNIX.