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