Changes: Ready for 5.13
[man-pages.git] / man3 / lrint.3
blob8a20e5b5de63109e302055cb2f2585fabd5abc5d
1 .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
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.
9 .\"
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.
14 .\"
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
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .TH LRINT 3  2021-03-22 "" "Linux Programmer's Manual"
28 .SH NAME
29 lrint, lrintf, lrintl, llrint, llrintf, llrintl \- round to nearest integer
30 .SH SYNOPSIS
31 .nf
32 .B #include <math.h>
33 .PP
34 .BI "long lrint(double " x );
35 .BI "long lrintf(float " x );
36 .BI "long lrintl(long double " x );
37 .PP
38 .BI "long long llrint(double " x );
39 .BI "long long llrintf(float " x );
40 .BI "long long llrintl(long double " x );
41 .fi
42 .PP
43 Link with \fI\-lm\fP.
44 .PP
45 .RS -4
46 Feature Test Macro Requirements for glibc (see
47 .BR feature_test_macros (7)):
48 .RE
49 .PP
50 All functions shown above:
51 .nf
52     _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
53 .fi
54 .SH DESCRIPTION
55 These functions round their argument to the nearest integer value,
56 using the current rounding direction (see
57 .BR fesetround (3)).
58 .PP
59 Note that unlike the
60 .BR rint (3)
61 family of functions,
62 the return type of these functions differs from
63 that of their arguments.
64 .SH RETURN VALUE
65 These functions return the rounded integer value.
66 .PP
68 .I x
69 is a NaN or an infinity,
70 or the rounded value is too large to be stored in a
71 .I long
72 .RI ( "long long"
73 in the case of the
74 .B ll*
75 functions),
76 then a domain error occurs, and the return value is unspecified.
77 .\" The return value is -(LONG_MAX - 1) or -(LLONG_MAX -1)
78 .SH ERRORS
79 See
80 .BR math_error (7)
81 for information on how to determine whether an error has occurred
82 when calling these functions.
83 .PP
84 The following errors can occur:
85 .TP
86 Domain error: \fIx\fP is a NaN or infinite, or the rounded value is too large
87 .\" .I errno
88 .\" is set to
89 .\" .BR EDOM .
90 An invalid floating-point exception
91 .RB ( FE_INVALID )
92 is raised.
93 .PP
94 These functions do not set
95 .IR errno .
96 .\" FIXME . Is it intentional that these functions do not set errno?
97 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6798
98 .SH VERSIONS
99 These functions first appeared in glibc in version 2.1.
100 .SH ATTRIBUTES
101 For an explanation of the terms used in this section, see
102 .BR attributes (7).
103 .ad l
106 allbox;
107 lbx lb lb
108 l l l.
109 Interface       Attribute       Value
111 .BR lrint (),
112 .BR lrintf (),
113 .BR lrintl (),
114 .BR llrint (),
115 .BR llrintf (),
116 .BR llrintl ()
117 T}      Thread safety   MT-Safe
121 .sp 1
122 .SH CONFORMING TO
123 C99, POSIX.1-2001, POSIX.1-2008.
124 .SH SEE ALSO
125 .BR ceil (3),
126 .BR floor (3),
127 .BR lround (3),
128 .BR nearbyint (3),
129 .BR rint (3),
130 .BR round (3)