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.\" $FreeBSD$ 26.\" 27.Dd January 13, 2008 28.Dt LRINT 3 29.Os 30.Sh NAME 31.Nm llrint , 32.Nm llrintf , 33.Nm llrintl , 34.Nm lrint , 35.Nm lrintf , 36.Nm lrintl 37.Nd "convert to integer" 38.Sh LIBRARY 39.Lb libm 40.Sh SYNOPSIS 41.In math.h 42.Ft "long long" 43.Fn llrint "double x" 44.Ft "long long" 45.Fn llrintf "float x" 46.Ft "long long" 47.Fn llrintl "long double x" 48.Ft long 49.Fn lrint "double x" 50.Ft long 51.Fn lrintf "float x" 52.Ft long 53.Fn lrintl "long double x" 54.Sh DESCRIPTION 55The 56.Fn lrint 57function returns the integer nearest to its argument 58.Fa x 59according to the current rounding mode. 60If the rounded result is too large to be represented as a 61.Vt long 62value, an invalid exception is raised and the return value is undefined. 63Otherwise, if 64.Fa x 65is not an integer, 66.Fn lrint 67raises an inexact exception. 68When the rounded result is representable as a 69.Vt long , 70the expression 71.Fn lrint x 72is equivalent to 73.Po Vt long Pc Ns Fn rint x 74(although the former may be more efficient). 75.Pp 76The 77.Fn llrint , 78.Fn llrintf , 79.Fn llrintl , 80.Fn lrintf , 81and 82.Fn lrintl 83functions differ from 84.Fn lrint 85only in their input and output types. 86.Sh SEE ALSO 87.Xr lround 3 , 88.Xr math 3 , 89.Xr rint 3 , 90.Xr round 3 91.Sh STANDARDS 92These functions conform to 93.St -isoC-99 . 94.Sh HISTORY 95The 96.Fn llrint , 97.Fn llrintf , 98.Fn lrint , 99and 100.Fn lrintf 101routines first appeared in 102.Fx 5.4 . 103The long double variants were introduced in 104.Fx 8.0 . 105