]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 2001 Andries Brouwer <aeb@cwi.nl>. |
e1520273 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 | .\" |
1ae6b2c7 | 7 | .TH LROUND 3 2021-03-22 GNU "Linux Programmer's Manual" |
fea681da | 8 | .SH NAME |
c13182ef | 9 | lround, lroundf, lroundl, llround, llroundf, llroundl \- round to |
f6cf8f80 | 10 | nearest integer |
ab50e426 AC |
11 | .SH LIBRARY |
12 | Math library | |
8fc3b2cf | 13 | .RI ( libm ", " \-lm ) |
fea681da MK |
14 | .SH SYNOPSIS |
15 | .nf | |
16 | .B #include <math.h> | |
68e4db0a | 17 | .PP |
ae85f653 AC |
18 | .BI "long lround(double " x ); |
19 | .BI "long lroundf(float " x ); | |
20 | .BI "long lroundl(long double " x ); | |
68e4db0a | 21 | .PP |
ae85f653 AC |
22 | .BI "long long llround(double " x ); |
23 | .BI "long long llroundf(float " x ); | |
24 | .BI "long long llroundl(long double " x ); | |
fea681da | 25 | .fi |
68e4db0a | 26 | .PP |
d39ad78f | 27 | .RS -4 |
cc4615cc MK |
28 | Feature Test Macro Requirements for glibc (see |
29 | .BR feature_test_macros (7)): | |
d39ad78f | 30 | .RE |
68e4db0a | 31 | .PP |
cc4615cc | 32 | All functions shown above: |
9d2adbae | 33 | .nf |
5c10d2c5 | 34 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae | 35 | .fi |
fea681da MK |
36 | .SH DESCRIPTION |
37 | These functions round their argument to the nearest integer value, | |
ce08dedc | 38 | rounding halfway cases away from zero, |
5dcc3b66 MK |
39 | regardless of the current rounding direction (see |
40 | .BR fenv (3)). | |
847e0d88 | 41 | .PP |
14d70713 MK |
42 | Note that unlike the |
43 | .BR round (3) | |
44 | and | |
9dc0b7df | 45 | .BR ceil (3), |
14d70713 | 46 | functions, the return type of these functions differs from |
9dc0b7df | 47 | that of their arguments. |
47297adb | 48 | .SH RETURN VALUE |
e1520273 | 49 | These functions return the rounded integer value. |
847e0d88 | 50 | .PP |
e1520273 MK |
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* | |
a27180c8 | 59 | functions), |
efe294cb | 60 | then a domain error occurs, and the return value is unspecified. |
e1520273 | 61 | .\" The return value is -(LONG_MAX - 1) or -(LLONG_MAX -1) |
fea681da | 62 | .SH ERRORS |
e1520273 MK |
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 | .PP | |
68 | The following errors can occur: | |
fea681da | 69 | .TP |
e1520273 MK |
70 | Domain error: \fIx\fP 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 | .PP | |
78 | These functions do not set | |
79 | .IR errno . | |
80 | .\" FIXME . Is it intentional that these functions do not set errno? | |
81 | .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6797 | |
f0d7ce1d MK |
82 | .SH VERSIONS |
83 | These functions first appeared in glibc in version 2.1. | |
df348165 | 84 | .SH ATTRIBUTES |
6c2b814e PH |
85 | For an explanation of the terms used in this section, see |
86 | .BR attributes (7). | |
c466875e MK |
87 | .ad l |
88 | .nh | |
6c2b814e PH |
89 | .TS |
90 | allbox; | |
c466875e | 91 | lbx lb lb |
6c2b814e PH |
92 | l l l. |
93 | Interface Attribute Value | |
94 | T{ | |
df348165 PH |
95 | .BR lround (), |
96 | .BR lroundf (), | |
97 | .BR lroundl (), | |
98 | .BR llround (), | |
99 | .BR llroundf (), | |
df348165 | 100 | .BR llroundl () |
6c2b814e PH |
101 | T} Thread safety MT-Safe |
102 | .TE | |
c466875e MK |
103 | .hy |
104 | .ad | |
105 | .sp 1 | |
47297adb | 106 | .SH CONFORMING TO |
9a74e018 | 107 | C99, POSIX.1-2001, POSIX.1-2008. |
47297adb | 108 | .SH SEE ALSO |
fea681da MK |
109 | .BR ceil (3), |
110 | .BR floor (3), | |
111 | .BR lrint (3), | |
112 | .BR nearbyint (3), | |
113 | .BR rint (3), | |
114 | .BR round (3) |