xref: /freebsd/lib/msun/man/lround.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
12aac156dSDavid Schultz.\" Copyright (c) 2005 David Schultz <das@FreeBSD.org>
22aac156dSDavid Schultz.\" All rights reserved.
32aac156dSDavid Schultz.\"
42aac156dSDavid Schultz.\" Redistribution and use in source and binary forms, with or without
52aac156dSDavid Schultz.\" modification, are permitted provided that the following conditions
62aac156dSDavid Schultz.\" are met:
72aac156dSDavid Schultz.\" 1. Redistributions of source code must retain the above copyright
82aac156dSDavid Schultz.\"    notice, this list of conditions and the following disclaimer.
92aac156dSDavid Schultz.\" 2. Redistributions in binary form must reproduce the above copyright
102aac156dSDavid Schultz.\"    notice, this list of conditions and the following disclaimer in the
112aac156dSDavid Schultz.\"    documentation and/or other materials provided with the distribution.
122aac156dSDavid Schultz.\"
132aac156dSDavid Schultz.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
142aac156dSDavid Schultz.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
152aac156dSDavid Schultz.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
162aac156dSDavid Schultz.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
172aac156dSDavid Schultz.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
182aac156dSDavid Schultz.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
192aac156dSDavid Schultz.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
202aac156dSDavid Schultz.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
212aac156dSDavid Schultz.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
222aac156dSDavid Schultz.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
232aac156dSDavid Schultz.\" SUCH DAMAGE.
242aac156dSDavid Schultz.\"
2507f3bc5bSDavid Schultz.Dd April 7, 2005
262aac156dSDavid Schultz.Dt LROUND 3
272aac156dSDavid Schultz.Os
282aac156dSDavid Schultz.Sh NAME
292aac156dSDavid Schultz.Nm llround ,
302aac156dSDavid Schultz.Nm llroundf ,
3107f3bc5bSDavid Schultz.Nm llroundl ,
322aac156dSDavid Schultz.Nm lround ,
3307f3bc5bSDavid Schultz.Nm lroundf ,
3407f3bc5bSDavid Schultz.Nm lroundl
3583e0359dSRuslan Ermilov.Nd "convert to nearest integral value"
362aac156dSDavid Schultz.Sh LIBRARY
372aac156dSDavid Schultz.Lb libm
382aac156dSDavid Schultz.Sh SYNOPSIS
392aac156dSDavid Schultz.In math.h
4083e0359dSRuslan Ermilov.Ft "long long"
412aac156dSDavid Schultz.Fn llround "double x"
4283e0359dSRuslan Ermilov.Ft "long long"
432aac156dSDavid Schultz.Fn llroundf "float x"
4407f3bc5bSDavid Schultz.Ft "long long"
4507f3bc5bSDavid Schultz.Fn llroundl "long double x"
462aac156dSDavid Schultz.Ft long
472aac156dSDavid Schultz.Fn lround "double x"
482aac156dSDavid Schultz.Ft long
492aac156dSDavid Schultz.Fn lroundf "float x"
5007f3bc5bSDavid Schultz.Ft long
5107f3bc5bSDavid Schultz.Fn lroundl "long double x"
522aac156dSDavid Schultz.Sh DESCRIPTION
532aac156dSDavid SchultzThe
542aac156dSDavid Schultz.Fn lround
552aac156dSDavid Schultzfunction returns the integer nearest to its argument
562aac156dSDavid Schultz.Fa x ,
572aac156dSDavid Schultzrounding away from zero in halfway cases.
582aac156dSDavid SchultzIf the rounded result is too large to be represented as a
5983e0359dSRuslan Ermilov.Vt long
602aac156dSDavid Schultzvalue, an invalid exception is raised and the return value is undefined.
612aac156dSDavid SchultzOtherwise, if
622aac156dSDavid Schultz.Fa x
632aac156dSDavid Schultzis not an integer,
642aac156dSDavid Schultz.Fn lround
652aac156dSDavid Schultzmay raise an inexact exception.
662aac156dSDavid SchultzWhen the rounded result is representable as a
6783e0359dSRuslan Ermilov.Vt long ,
682aac156dSDavid Schultzthe expression
6983e0359dSRuslan Ermilov.Fn lround x
702aac156dSDavid Schultzis equivalent to
7183e0359dSRuslan Ermilov.Po Vt long Pc Ns Fn round x
7283e0359dSRuslan Ermilov(although the former may be more efficient).
732aac156dSDavid Schultz.Pp
742aac156dSDavid SchultzThe
752aac156dSDavid Schultz.Fn llround ,
762aac156dSDavid Schultz.Fn llroundf ,
7707f3bc5bSDavid Schultz.Fn llroundl ,
782aac156dSDavid Schultz.Fn lroundf
7907f3bc5bSDavid Schultzand
8007f3bc5bSDavid Schultz.Fn lroundl
812aac156dSDavid Schultzfunctions differ from
822aac156dSDavid Schultz.Fn lround
832aac156dSDavid Schultzonly in their input and output types.
842aac156dSDavid Schultz.Sh SEE ALSO
852aac156dSDavid Schultz.Xr lrint 3 ,
862aac156dSDavid Schultz.Xr math 3 ,
872aac156dSDavid Schultz.Xr rint 3 ,
882aac156dSDavid Schultz.Xr round 3
892aac156dSDavid Schultz.Sh STANDARDS
902aac156dSDavid SchultzThe
912aac156dSDavid Schultz.Fn llround ,
922aac156dSDavid Schultz.Fn llroundf ,
9307f3bc5bSDavid Schultz.Fn llroundl ,
942aac156dSDavid Schultz.Fn lround ,
9507f3bc5bSDavid Schultz.Fn lroundf ,
962aac156dSDavid Schultzand
9707f3bc5bSDavid Schultz.Fn lroundl
982aac156dSDavid Schultzfunctions conform to
992aac156dSDavid Schultz.St -isoC-99 .
1002aac156dSDavid Schultz.Sh HISTORY
10107f3bc5bSDavid SchultzThe
102f789cb82SRuslan Ermilov.Vt float
10307f3bc5bSDavid Schultzand
104f789cb82SRuslan Ermilov.Vt double
10507f3bc5bSDavid Schultzversions of these routines first appeared in
1062aac156dSDavid Schultz.Fx 5.4 .
10707f3bc5bSDavid SchultzThe
108f789cb82SRuslan Ermilov.Vt "long double"
10907f3bc5bSDavid Schultzversions appeared in
11007f3bc5bSDavid Schultz.Fx 6.0 .
111