1LRINT(3) Linux Programmer's Manual LRINT(3)
2
3
4
6 lrint, lrintf, lrintl, llrint, llrintf, llrintl - round to nearest in‐
7 teger
8
10 #include <math.h>
11
12 long lrint(double x);
13 long lrintf(float x);
14 long lrintl(long double x);
15
16 long long llrint(double x);
17 long long llrintf(float x);
18 long long llrintl(long double x);
19
20 Link with -lm.
21
22 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
23
24 All functions shown above:
25 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
26
28 These functions round their argument to the nearest integer value, us‐
29 ing the current rounding direction (see fesetround(3)).
30
31 Note that unlike the rint(3) family of functions, the return type of
32 these functions differs from that of their arguments.
33
35 These functions return the rounded integer value.
36
37 If x is a NaN or an infinity, or the rounded value is too large to be
38 stored in a long (long long in the case of the ll* functions), then a
39 domain error occurs, and the return value is unspecified.
40
42 See math_error(7) for information on how to determine whether an error
43 has occurred when calling these functions.
44
45 The following errors can occur:
46
47 Domain error: x is a NaN or infinite, or the rounded value is too large
48 An invalid floating-point exception (FE_INVALID) is raised.
49
50 These functions do not set errno.
51
53 These functions first appeared in glibc in version 2.1.
54
56 For an explanation of the terms used in this section, see at‐
57 tributes(7).
58
59 ┌────────────────────────────────────────────┬───────────────┬─────────┐
60 │Interface │ Attribute │ Value │
61 ├────────────────────────────────────────────┼───────────────┼─────────┤
62 │lrint(), lrintf(), lrintl(), llrint(), │ Thread safety │ MT-Safe │
63 │llrintf(), llrintl() │ │ │
64 └────────────────────────────────────────────┴───────────────┴─────────┘
65
67 C99, POSIX.1-2001, POSIX.1-2008.
68
70 ceil(3), floor(3), lround(3), nearbyint(3), rint(3), round(3)
71
73 This page is part of release 5.13 of the Linux man-pages project. A
74 description of the project, information about reporting bugs, and the
75 latest version of this page, can be found at
76 https://www.kernel.org/doc/man-pages/.
77
78
79
80 2021-03-22 LRINT(3)