]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>. |
bf8e66b1 MK |
2 | .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk |
3 | .\" <mtk.manpages@gmail.com> | |
fea681da | 4 | .\" |
5fbde956 | 5 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da | 6 | .\" |
4c1c5274 | 7 | .TH lrint 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
8 | .SH NAME |
9 | lrint, lrintf, lrintl, llrint, llrintf, llrintl \- round to nearest integer | |
87811097 AC |
10 | .SH LIBRARY |
11 | Math library | |
8fc3b2cf | 12 | .RI ( libm ", " \-lm ) |
fea681da MK |
13 | .SH SYNOPSIS |
14 | .nf | |
15 | .B #include <math.h> | |
68e4db0a | 16 | .PP |
ae85f653 AC |
17 | .BI "long lrint(double " x ); |
18 | .BI "long lrintf(float " x ); | |
19 | .BI "long lrintl(long double " x ); | |
68e4db0a | 20 | .PP |
ae85f653 AC |
21 | .BI "long long llrint(double " x ); |
22 | .BI "long long llrintf(float " x ); | |
23 | .BI "long long llrintl(long double " x ); | |
fea681da | 24 | .fi |
68e4db0a | 25 | .PP |
d39ad78f | 26 | .RS -4 |
cc4615cc MK |
27 | Feature Test Macro Requirements for glibc (see |
28 | .BR feature_test_macros (7)): | |
d39ad78f | 29 | .RE |
68e4db0a | 30 | .PP |
cc4615cc | 31 | All functions shown above: |
9d2adbae | 32 | .nf |
5c10d2c5 | 33 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae | 34 | .fi |
fea681da MK |
35 | .SH DESCRIPTION |
36 | These functions round their argument to the nearest integer value, | |
bf8e66b1 MK |
37 | using the current rounding direction (see |
38 | .BR fesetround (3)). | |
847e0d88 | 39 | .PP |
6f9ea778 MK |
40 | Note that unlike the |
41 | .BR rint (3) | |
42 | family of functions, | |
43 | the return type of these functions differs from | |
bf8e66b1 | 44 | that of their arguments. |
47297adb | 45 | .SH RETURN VALUE |
bf8e66b1 | 46 | These functions return the rounded integer value. |
847e0d88 | 47 | .PP |
bf8e66b1 MK |
48 | If |
49 | .I x | |
50 | is a NaN or an infinity, | |
51 | or the rounded value is too large to be stored in a | |
52 | .I long | |
53 | .RI ( "long long" | |
54 | in the case of the | |
55 | .B ll* | |
3f947a92 | 56 | functions), |
efe294cb | 57 | then a domain error occurs, and the return value is unspecified. |
bf8e66b1 | 58 | .\" The return value is -(LONG_MAX - 1) or -(LLONG_MAX -1) |
fea681da | 59 | .SH ERRORS |
bf8e66b1 MK |
60 | See |
61 | .BR math_error (7) | |
62 | for information on how to determine whether an error has occurred | |
63 | when calling these functions. | |
64 | .PP | |
65 | The following errors can occur: | |
fea681da | 66 | .TP |
bf8e66b1 MK |
67 | Domain error: \fIx\fP is a NaN or infinite, or the rounded value is too large |
68 | .\" .I errno | |
69 | .\" is set to | |
70 | .\" .BR EDOM . | |
71 | An invalid floating-point exception | |
72 | .RB ( FE_INVALID ) | |
73 | is raised. | |
74 | .PP | |
75 | These functions do not set | |
76 | .IR errno . | |
77 | .\" FIXME . Is it intentional that these functions do not set errno? | |
78 | .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6798 | |
f0d7ce1d MK |
79 | .SH VERSIONS |
80 | These functions first appeared in glibc in version 2.1. | |
5399a562 | 81 | .SH ATTRIBUTES |
b51ab590 PH |
82 | For an explanation of the terms used in this section, see |
83 | .BR attributes (7). | |
c466875e MK |
84 | .ad l |
85 | .nh | |
b51ab590 PH |
86 | .TS |
87 | allbox; | |
c466875e | 88 | lbx lb lb |
b51ab590 PH |
89 | l l l. |
90 | Interface Attribute Value | |
91 | T{ | |
5399a562 PH |
92 | .BR lrint (), |
93 | .BR lrintf (), | |
94 | .BR lrintl (), | |
95 | .BR llrint (), | |
96 | .BR llrintf (), | |
5399a562 | 97 | .BR llrintl () |
b51ab590 PH |
98 | T} Thread safety MT-Safe |
99 | .TE | |
c466875e MK |
100 | .hy |
101 | .ad | |
102 | .sp 1 | |
3113c7f3 | 103 | .SH STANDARDS |
9a74e018 | 104 | C99, POSIX.1-2001, POSIX.1-2008. |
47297adb | 105 | .SH SEE ALSO |
fea681da MK |
106 | .BR ceil (3), |
107 | .BR floor (3), | |
108 | .BR lround (3), | |
109 | .BR nearbyint (3), | |
110 | .BR rint (3), | |
111 | .BR round (3) |