]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/rint.3
system.3: wfix
[thirdparty/man-pages.git] / man3 / rint.3
CommitLineData
fea681da 1.\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>.
2517f764
MK
2.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3.\" <mtk.manpages@gmail.com>
fea681da 4.\"
93015253 5.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
6.\" Permission is granted to make and distribute verbatim copies of this
7.\" manual provided the copyright notice and this permission notice are
8.\" preserved on all copies.
9.\"
10.\" Permission is granted to copy and distribute modified versions of this
11.\" manual under the conditions for verbatim copying, provided that the
12.\" entire resulting derived work is distributed under the terms of a
13.\" permission notice identical to this one.
c13182ef 14.\"
fea681da
MK
15.\" Since the Linux kernel and libraries are constantly changing, this
16.\" manual page may be incorrect or out-of-date. The author(s) assume no
17.\" responsibility for errors or omissions, or for damages resulting from
18.\" the use of the information contained herein. The author(s) may not
19.\" have taken the same level of care in the production of this manual,
20.\" which is licensed free of charge, as they might when working
21.\" professionally.
c13182ef 22.\"
fea681da
MK
23.\" Formatted or processed versions of this manual, if unaccompanied by
24.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 25.\" %%%LICENSE_END
fea681da 26.\"
4b8c67d9 27.TH RINT 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da 28.SH NAME
2517f764
MK
29nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl \- round
30to nearest integer
fea681da
MK
31.SH SYNOPSIS
32.nf
33.B #include <math.h>
68e4db0a 34.PP
fea681da 35.BI "double nearbyint(double " x );
fea681da 36.BI "float nearbyintf(float " x );
fea681da 37.BI "long double nearbyintl(long double " x );
68e4db0a 38.PP
fea681da 39.BI "double rint(double " x );
fea681da 40.BI "float rintf(float " x );
fea681da
MK
41.BI "long double rintl(long double " x );
42.fi
68e4db0a 43.PP
20c58d70 44Link with \fI\-lm\fP.
68e4db0a 45.PP
cc4615cc
MK
46.in -4n
47Feature Test Macro Requirements for glibc (see
48.BR feature_test_macros (7)):
49.in
68e4db0a 50.PP
cc4615cc
MK
51.ad l
52.BR nearbyint (),
53.BR nearbyintf (),
54.BR nearbyintl ():
27311437 55.RS 4
cd2d5ec1 56_POSIX_C_SOURCE\ >=\ 200112L || _ISOC99_SOURCE
27311437 57.RE
cc4615cc 58.br
2517f764 59.BR rint ():
27311437 60.RS 4
636ed4d5
MK
61_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
62 || _XOPEN_SOURCE\ >=\ 500
cf7fa0a1 63.\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
636ed4d5
MK
64 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
65 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
27311437 66.RE
2517f764 67.br
cc4615cc
MK
68.BR rintf (),
69.BR rintl ():
27311437 70.RS 4
636ed4d5
MK
71_ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
72 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
73 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
27311437 74.RE
cc4615cc 75.ad b
fea681da
MK
76.SH DESCRIPTION
77The
39ea0230
PH
78.BR nearbyint (),
79.BR nearbyintf (),
80and
81.BR nearbyintl ()
2517f764
MK
82functions round their argument to an integer value in floating-point
83format, using the current rounding direction (see
84.BR fesetround (3))
85and without raising the
fea681da 86.I inexact
6bea3242
MK
87exception.
88When the current rounding direction is to nearest, these
526c53f0
MT
89functions round halfway cases to the even integer in accordance with
90IEEE-754.
dd3568a1 91.PP
fea681da 92The
39ea0230
PH
93.BR rint (),
94.BR rintf (),
95and
96.BR rintl ()
fea681da
MK
97functions do the same, but will raise the
98.I inexact
2517f764
MK
99exception
100.RB ( FE_INEXACT ,
101checkable via
102.BR fetestexcept (3))
103when the result differs in value from the argument.
47297adb 104.SH RETURN VALUE
2517f764 105These functions return the rounded integer value.
847e0d88 106.PP
022671eb
MK
107If
108.I x
109is integral, +0, \-0, NaN, or infinite,
110.I x
111itself is returned.
fea681da 112.SH ERRORS
2517f764 113No errors occur.
efe294cb 114POSIX.1-2001 documents a range error for overflows, but see NOTES.
36981c13 115.SH ATTRIBUTES
dd47b706
PH
116For an explanation of the terms used in this section, see
117.BR attributes (7).
118.TS
119allbox;
120lbw26 lb lb
121l l l.
122Interface Attribute Value
123T{
36981c13
PH
124.BR nearbyint (),
125.BR nearbyintf (),
dd47b706 126.br
36981c13
PH
127.BR nearbyintl (),
128.BR rint (),
dd47b706 129.br
36981c13 130.BR rintf (),
36981c13 131.BR rintl ()
dd47b706
PH
132T} Thread safety MT-Safe
133.TE
47297adb 134.SH CONFORMING TO
9a74e018 135C99, POSIX.1-2001, POSIX.1-2008.
fea681da 136.SH NOTES
68e1685c 137SUSv2 and POSIX.1-2001 contain text about overflow (which might set
fea681da 138.I errno
2f0af33b
MK
139to
140.BR ERANGE ,
2517f764
MK
141or raise an
142.B FE_OVERFLOW
143exception).
fea681da
MK
144In practice, the result cannot overflow on any current machine,
145so this error-handling stuff is just nonsense.
146(More precisely, overflow can happen only when the maximum value
147of the exponent is smaller than the number of mantissa bits.
2517f764
MK
148For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
149the maximum value of the exponent is 128 (respectively, 1024),
150and the number of mantissa bits is 24 (respectively, 53).)
847e0d88 151.PP
2517f764
MK
152If you want to store the rounded value in an integer type,
153you probably want to use one of the functions described in
154.BR lrint (3)
155instead.
47297adb 156.SH SEE ALSO
fea681da
MK
157.BR ceil (3),
158.BR floor (3),
159.BR lrint (3),
fea681da
MK
160.BR round (3),
161.BR trunc (3)