xref: /freebsd/lib/msun/man/lrint.3 (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1.\" Copyright (c) 2005 David Schultz <das@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.Dd January 13, 2008
26.Dt LRINT 3
27.Os
28.Sh NAME
29.Nm llrint ,
30.Nm llrintf ,
31.Nm llrintl ,
32.Nm lrint ,
33.Nm lrintf ,
34.Nm lrintl
35.Nd "convert to integer"
36.Sh LIBRARY
37.Lb libm
38.Sh SYNOPSIS
39.In math.h
40.Ft "long long"
41.Fn llrint "double x"
42.Ft "long long"
43.Fn llrintf "float x"
44.Ft "long long"
45.Fn llrintl "long double x"
46.Ft long
47.Fn lrint "double x"
48.Ft long
49.Fn lrintf "float x"
50.Ft long
51.Fn lrintl "long double x"
52.Sh DESCRIPTION
53The
54.Fn lrint
55function returns the integer nearest to its argument
56.Fa x
57according to the current rounding mode.
58If the rounded result is too large to be represented as a
59.Vt long
60value, an invalid exception is raised and the return value is undefined.
61Otherwise, if
62.Fa x
63is not an integer,
64.Fn lrint
65raises an inexact exception.
66When the rounded result is representable as a
67.Vt long ,
68the expression
69.Fn lrint x
70is equivalent to
71.Po Vt long Pc Ns Fn rint x
72(although the former may be more efficient).
73.Pp
74The
75.Fn llrint ,
76.Fn llrintf ,
77.Fn llrintl ,
78.Fn lrintf ,
79and
80.Fn lrintl
81functions differ from
82.Fn lrint
83only in their input and output types.
84.Sh SEE ALSO
85.Xr lround 3 ,
86.Xr math 3 ,
87.Xr rint 3 ,
88.Xr round 3
89.Sh STANDARDS
90These functions conform to
91.St -isoC-99 .
92.Sh HISTORY
93The
94.Fn llrint ,
95.Fn llrintf ,
96.Fn lrint ,
97and
98.Fn lrintf
99routines first appeared in
100.Fx 5.4 .
101The long double variants were introduced in
102.Fx 8.0 .
103