File: lround.3

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