1RINT(3) Linux Programmer's Manual RINT(3)
2
3
4
6 nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl - round to near‐
7 est integer
8
10 #include <math.h>
11
12 double nearbyint(double x);
13 float nearbyintf(float x);
14 long double nearbyintl(long double x);
15
16 double rint(double x);
17 float rintf(float x);
18 long double rintl(long double x);
19
20 Link with -lm.
21
22 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
23
24 nearbyint(), nearbyintf(), nearbyintl():
25 _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L ||
26 _ISOC99_SOURCE;
27 or cc -std=c99
28 rint():
29 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 ||
30 _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _ISOC99_SOURCE ||
31 _POSIX_C_SOURCE >= 200112L;
32 or cc -std=c99
33 rintf(), rintl():
34 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 ||
35 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
36 or cc -std=c99
37
39 The nearbyint() functions round their argument to an integer value in
40 floating-point format, using the current rounding direction (see fes‐
41 etround(3)) and without raising the inexact exception.
42
43 The rint() functions do the same, but will raise the inexact exception
44 (FE_INEXACT, checkable via fetestexcept(3)) when the result differs in
45 value from the argument.
46
48 These functions return the rounded integer value.
49
50 If x is integral, +0, -0, NaN, or infinite, x itself is returned.
51
53 No errors occur. POSIX.1-2001 documents a range error for overflows,
54 but see NOTES.
55
57 C99, POSIX.1-2001.
58
60 SUSv2 and POSIX.1-2001 contain text about overflow (which might set
61 errno to ERANGE, or raise an FE_OVERFLOW exception). In practice, the
62 result cannot overflow on any current machine, so this error-handling
63 stuff is just nonsense. (More precisely, overflow can happen only when
64 the maximum value of the exponent is smaller than the number of man‐
65 tissa bits. For the IEEE-754 standard 32-bit and 64-bit floating-point
66 numbers the maximum value of the exponent is 128 (respectively, 1024),
67 and the number of mantissa bits is 24 (respectively, 53).)
68
69 If you want to store the rounded value in an integer type, you probably
70 want to use one of the functions described in lrint(3) instead.
71
73 ceil(3), floor(3), lrint(3), round(3), trunc(3)
74
76 This page is part of release 3.53 of the Linux man-pages project. A
77 description of the project, and information about reporting bugs, can
78 be found at http://www.kernel.org/doc/man-pages/.
79
80
81
82 2010-09-20 RINT(3)