]>
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 | .\" |
93015253 | 5 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
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. | |
c13182ef | 14 | .\" |
fea681da MK |
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. | |
c13182ef | 22 | .\" |
fea681da MK |
23 | .\" Formatted or processed versions of this manual, if unaccompanied by |
24 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 25 | .\" %%%LICENSE_END |
fea681da | 26 | .\" |
97986708 | 27 | .TH LROUND 3 2016-03-15 "" "Linux Programmer's Manual" |
fea681da | 28 | .SH NAME |
c13182ef | 29 | lround, lroundf, lroundl, llround, llroundf, llroundl \- round to |
35478399 | 30 | nearest integer, away from zero |
fea681da MK |
31 | .SH SYNOPSIS |
32 | .nf | |
33 | .B #include <math.h> | |
68e4db0a | 34 | .PP |
fea681da MK |
35 | .BI "long int lround(double " x ); |
36 | .br | |
37 | .BI "long int lroundf(float " x ); | |
38 | .br | |
39 | .BI "long int lroundl(long double " x ); | |
68e4db0a | 40 | .PP |
fea681da MK |
41 | .BI "long long int llround(double " x ); |
42 | .br | |
43 | .BI "long long int llroundf(float " x ); | |
44 | .br | |
45 | .BI "long long int llroundl(long double " x ); | |
46 | .fi | |
68e4db0a | 47 | .PP |
cc4615cc | 48 | Link with \fI\-lm\fP. |
68e4db0a | 49 | .PP |
cc4615cc MK |
50 | .in -4n |
51 | Feature Test Macro Requirements for glibc (see | |
52 | .BR feature_test_macros (7)): | |
53 | .in | |
68e4db0a | 54 | .PP |
cc4615cc MK |
55 | .ad l |
56 | All functions shown above: | |
f1f0e4ed | 57 | .RS 4 |
e464f054 | 58 | _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L |
f1f0e4ed MK |
59 | .RE |
60 | .ad | |
fea681da MK |
61 | .SH DESCRIPTION |
62 | These functions round their argument to the nearest integer value, | |
5dcc3b66 MK |
63 | rounding away from zero, |
64 | regardless of the current rounding direction (see | |
65 | .BR fenv (3)). | |
847e0d88 | 66 | .PP |
14d70713 MK |
67 | Note that unlike the |
68 | .BR round (3) | |
69 | and | |
9dc0b7df | 70 | .BR ceil (3), |
14d70713 | 71 | functions, the return type of these functions differs from |
9dc0b7df | 72 | that of their arguments. |
47297adb | 73 | .SH RETURN VALUE |
e1520273 | 74 | These functions return the rounded integer value. |
847e0d88 | 75 | .PP |
e1520273 MK |
76 | If |
77 | .I x | |
78 | is a NaN or an infinity, | |
79 | or the rounded value is too large to be stored in a | |
80 | .I long | |
81 | .RI ( "long long" | |
82 | in the case of the | |
83 | .B ll* | |
a27180c8 | 84 | functions), |
efe294cb | 85 | then a domain error occurs, and the return value is unspecified. |
e1520273 | 86 | .\" The return value is -(LONG_MAX - 1) or -(LLONG_MAX -1) |
fea681da | 87 | .SH ERRORS |
e1520273 MK |
88 | See |
89 | .BR math_error (7) | |
90 | for information on how to determine whether an error has occurred | |
91 | when calling these functions. | |
92 | .PP | |
93 | The following errors can occur: | |
fea681da | 94 | .TP |
e1520273 MK |
95 | Domain error: \fIx\fP is a NaN or infinite, or the rounded value is too large |
96 | .\" .I errno | |
97 | .\" is set to | |
98 | .\" .BR EDOM . | |
99 | An invalid floating-point exception | |
100 | .RB ( FE_INVALID ) | |
101 | is raised. | |
102 | .PP | |
103 | These functions do not set | |
104 | .IR errno . | |
105 | .\" FIXME . Is it intentional that these functions do not set errno? | |
106 | .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6797 | |
f0d7ce1d MK |
107 | .SH VERSIONS |
108 | These functions first appeared in glibc in version 2.1. | |
df348165 | 109 | .SH ATTRIBUTES |
6c2b814e PH |
110 | For an explanation of the terms used in this section, see |
111 | .BR attributes (7). | |
112 | .TS | |
113 | allbox; | |
114 | lbw33 lb lb | |
115 | l l l. | |
116 | Interface Attribute Value | |
117 | T{ | |
df348165 PH |
118 | .BR lround (), |
119 | .BR lroundf (), | |
120 | .BR lroundl (), | |
6c2b814e | 121 | .br |
df348165 PH |
122 | .BR llround (), |
123 | .BR llroundf (), | |
df348165 | 124 | .BR llroundl () |
6c2b814e PH |
125 | T} Thread safety MT-Safe |
126 | .TE | |
47297adb | 127 | .SH CONFORMING TO |
9a74e018 | 128 | C99, POSIX.1-2001, POSIX.1-2008. |
47297adb | 129 | .SH SEE ALSO |
fea681da MK |
130 | .BR ceil (3), |
131 | .BR floor (3), | |
132 | .BR lrint (3), | |
133 | .BR nearbyint (3), | |
134 | .BR rint (3), | |
135 | .BR round (3) |