1 .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\" <mtk.manpages@gmail.com>
5 .\" %%%LICENSE_START(VERBATIM)
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.
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.
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
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
27 .TH RINT 3 2016-03-15 "" "Linux Programmer's Manual"
29 nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl \- round
35 .BI "double nearbyint(double " x );
37 .BI "float nearbyintf(float " x );
39 .BI "long double nearbyintl(long double " x );
41 .BI "double rint(double " x );
43 .BI "float rintf(float " x );
45 .BI "long double rintl(long double " x );
51 Feature Test Macro Requirements for glibc (see
52 .BR feature_test_macros (7)):
60 _POSIX_C_SOURCE\ >=\ 200112L || _ISOC99_SOURCE
65 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
66 || _XOPEN_SOURCE\ >=\ 500
67 .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
68 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
69 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
75 _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L
76 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
77 || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
86 functions round their argument to an integer value in floating-point
87 format, using the current rounding direction (see
89 and without raising the
92 When the current rounding direction is to nearest, these
93 functions round halfway cases to the even integer in accordance with
101 functions do the same, but will raise the
106 .BR fetestexcept (3))
107 when the result differs in value from the argument.
109 These functions return the rounded integer value.
113 is integral, +0, \-0, NaN, or infinite,
118 POSIX.1-2001 documents a range error for overflows, but see NOTES.
120 For an explanation of the terms used in this section, see
126 Interface Attribute Value
136 T} Thread safety MT-Safe
139 C99, POSIX.1-2001, POSIX.1-2008.
141 SUSv2 and POSIX.1-2001 contain text about overflow (which might set
148 In practice, the result cannot overflow on any current machine,
149 so this error-handling stuff is just nonsense.
150 (More precisely, overflow can happen only when the maximum value
151 of the exponent is smaller than the number of mantissa bits.
152 For the IEEE-754 standard 32-bit and 64-bit floating-point numbers
153 the maximum value of the exponent is 128 (respectively, 1024),
154 and the number of mantissa bits is 24 (respectively, 53).)
156 If you want to store the rounded value in an integer type,
157 you probably want to use one of the functions described in