1lround(3) Library Functions Manual lround(3)
2
3
4
6 lround, lroundf, lroundl, llround, llroundf, llroundl - round to near‐
7 est integer
8
10 Math library (libm, -lm)
11
13 #include <math.h>
14
15 long lround(double x);
16 long lroundf(float x);
17 long lroundl(long double x);
18
19 long long llround(double x);
20 long long llroundf(float x);
21 long long llroundl(long double x);
22
23 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
24
25 All functions shown above:
26 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
27
29 These functions round their argument to the nearest integer value,
30 rounding halfway cases away from zero, regardless of the current round‐
31 ing direction (see fenv(3)).
32
33 Note that unlike the round(3) and ceil(3), functions, the return type
34 of these functions differs from that of their arguments.
35
37 These functions return the rounded integer value.
38
39 If x is a NaN or an infinity, or the rounded value is too large to be
40 stored in a long (long long in the case of the ll* functions), then a
41 domain error occurs, and the return value is unspecified.
42
44 See math_error(7) for information on how to determine whether an error
45 has occurred when calling these functions.
46
47 The following errors can occur:
48
49 Domain error: x is a NaN or infinite, or the rounded value is too large
50 An invalid floating-point exception (FE_INVALID) is raised.
51
52 These functions do not set errno.
53
55 For an explanation of the terms used in this section, see at‐
56 tributes(7).
57
58 ┌────────────────────────────────────────────┬───────────────┬─────────┐
59 │Interface │ Attribute │ Value │
60 ├────────────────────────────────────────────┼───────────────┼─────────┤
61 │lround(), lroundf(), lroundl(), llround(), │ Thread safety │ MT-Safe │
62 │llroundf(), llroundl() │ │ │
63 └────────────────────────────────────────────┴───────────────┴─────────┘
64
66 C11, POSIX.1-2008.
67
69 glibc 2.1. C99, POSIX.1-2001.
70
72 ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)
73
74
75
76Linux man-pages 6.04 2023-03-30 lround(3)