Debian Codegraph @

upstream/debian-unstable/man3/lround.3

raw
1 '\" t
2 .\" Copyright 2001, Andries E. Brouwer <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH lround 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 lround, lroundf, lroundl, llround, llroundf, llroundl \- round to
10 nearest integer
11 .SH LIBRARY
12 Math library
13 .RI ( libm ,\~ \-lm )
14 .SH SYNOPSIS
15 .nf
16 .B #include <math.h>
17 .P
18 .BI "long lround(double " x );
19 .BI "long lroundf(float " x );
20 .BI "long lroundl(long double " x );
21 .P
22 .BI "long long llround(double " x );
23 .BI "long long llroundf(float " x );
24 .BI "long long llroundl(long double " x );
25 .fi
26 .P
27 .RS -4
28 Feature Test Macro Requirements for glibc (see
29 .BR feature_test_macros (7)):
30 .RE
31 .P
32 All functions shown above:
33 .nf
34 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
35 .fi
36 .SH DESCRIPTION
37 These functions round their argument to the nearest integer value,
38 rounding halfway cases away from zero,
39 regardless of the current rounding direction (see
40 .BR fenv (3)).
41 .P
42 Note that unlike the
43 .BR round (3)
44 and
45 .BR ceil (3),
46 functions, the return type of these functions differs from
47 that of their arguments.
48 .SH RETURN VALUE
49 These functions return the rounded integer value.
50 .P
51 If
52 .I x
53 is a NaN or an infinity,
54 or the rounded value is too large to be stored in a
55 .I long
56 .RI ( "long long"
57 in the case of the
58 .B ll*
59 functions),
60 then a domain error occurs, and the return value is unspecified.
61 .\" The return value is -(LONG_MAX - 1) or -(LLONG_MAX -1)
62 .SH ERRORS
63 See
64 .BR math_error (7)
65 for information on how to determine whether an error has occurred
66 when calling these functions.
67 .P
68 The following errors can occur:
69 .TP
70 Domain error: \f[I]x\f[] is a NaN or infinite, or the rounded value is too large
71 .\" .I errno
72 .\" is set to
73 .\" .BR EDOM .
74 An invalid floating-point exception
75 .RB ( FE_INVALID )
76 is raised.
77 .P
78 These functions do not set
79 .IR errno .
80 .\" FIXME . Is it intentional that these functions do not set errno?
81 .\" Bug raised: https://www.sourceware.org/bugzilla/show_bug.cgi?id=6797
82 .SH ATTRIBUTES
83 For an explanation of the terms used in this section, see
84 .BR attributes (7).
85 .TS
86 allbox;
87 lbx lb lb
88 l l l.
89 Interface Attribute Value
90 T{
91 .na
92 .nh
93 .BR lround (),
94 .BR lroundf (),
95 .BR lroundl (),
96 .BR llround (),
97 .BR llroundf (),
98 .BR llroundl ()
99 T} Thread safety MT-Safe
100 .TE
101 .SH STANDARDS
102 C11, POSIX.1-2008.
103 .SH HISTORY
104 glibc 2.1.
105 C99, POSIX.1-2001.
106 .SH SEE ALSO
107 .BR ceil (3),
108 .BR floor (3),
109 .BR lrint (3),
110 .BR nearbyint (3),
111 .BR rint (3),
112 .BR round (3)