]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/rint.3
futex.2, netlink.3, stdin.3, wavelan.4, netlink.7: srcfix
[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
MK
4.\"
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
c13182ef 13.\"
fea681da
MK
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
c13182ef 21.\"
fea681da
MK
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\"
50831f9b 25.TH RINT 3 2010-09-20 "" "Linux Programmer's Manual"
fea681da 26.SH NAME
2517f764
MK
27nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl \- round
28to nearest integer
fea681da
MK
29.SH SYNOPSIS
30.nf
31.B #include <math.h>
32.sp
33.BI "double nearbyint(double " x );
34.br
35.BI "float nearbyintf(float " x );
36.br
37.BI "long double nearbyintl(long double " x );
38.sp
39.BI "double rint(double " x );
40.br
41.BI "float rintf(float " x );
42.br
43.BI "long double rintl(long double " x );
44.fi
45.sp
20c58d70 46Link with \fI\-lm\fP.
cc4615cc
MK
47.sp
48.in -4n
49Feature Test Macro Requirements for glibc (see
50.BR feature_test_macros (7)):
51.in
52.sp
53.ad l
54.BR nearbyint (),
55.BR nearbyintf (),
56.BR nearbyintl ():
27311437 57.RS 4
98dbe7af 58_XOPEN_SOURCE\ >=\ 600 || _POSIX_C_SOURCE\ >=\ 200112L || _ISOC99_SOURCE;
27311437
MK
59.br
60or
cc4615cc 61.I cc\ -std=c99
27311437 62.RE
cc4615cc 63.br
2517f764 64.BR rint ():
27311437
MK
65.RS 4
66_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
67_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED || _ISOC99_SOURCE ||
98dbe7af 68_POSIX_C_SOURCE\ >=\ 200112L;
27311437
MK
69.br
70or
2517f764 71.I cc\ -std=c99
27311437 72.RE
2517f764 73.br
cc4615cc
MK
74.BR rintf (),
75.BR rintl ():
27311437
MK
76.RS 4
77_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
98dbe7af 78_POSIX_C_SOURCE\ >=\ 200112L;
27311437
MK
79.br
80or
cc4615cc 81.I cc\ -std=c99
27311437 82.RE
cc4615cc 83.ad b
fea681da
MK
84.SH DESCRIPTION
85The
e511ffb6 86.BR nearbyint ()
2517f764
MK
87functions round their argument to an integer value in floating-point
88format, using the current rounding direction (see
89.BR fesetround (3))
90and without raising the
fea681da
MK
91.I inexact
92exception.
93.LP
94The
e511ffb6 95.BR rint ()
fea681da
MK
96functions do the same, but will raise the
97.I inexact
2517f764
MK
98exception
99.RB ( FE_INEXACT ,
100checkable via
101.BR fetestexcept (3))
102when the result differs in value from the argument.
47297adb 103.SH RETURN VALUE
2517f764
MK
104These functions return the rounded integer value.
105
106If \fIx\fP is integral, +0, \-0, NaN, or infinite,
fea681da
MK
107\fIx\fP itself is returned.
108.SH ERRORS
2517f764 109No errors occur.
efe294cb 110POSIX.1-2001 documents a range error for overflows, but see NOTES.
47297adb 111.SH CONFORMING TO
2517f764 112C99, POSIX.1-2001.
fea681da 113.SH NOTES
68e1685c 114SUSv2 and POSIX.1-2001 contain text about overflow (which might set
fea681da 115.I errno
2f0af33b
MK
116to
117.BR ERANGE ,
2517f764
MK
118or raise an
119.B FE_OVERFLOW
120exception).
fea681da
MK
121In practice, the result cannot overflow on any current machine,
122so this error-handling stuff is just nonsense.
123(More precisely, overflow can happen only when the maximum value
124of the exponent is smaller than the number of mantissa bits.
2517f764
MK
125For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
126the maximum value of the exponent is 128 (respectively, 1024),
127and the number of mantissa bits is 24 (respectively, 53).)
128
129If you want to store the rounded value in an integer type,
130you probably want to use one of the functions described in
131.BR lrint (3)
132instead.
47297adb 133.SH SEE ALSO
fea681da
MK
134.BR ceil (3),
135.BR floor (3),
136.BR lrint (3),
fea681da
MK
137.BR round (3),
138.BR trunc (3)