This work is based in part on code from NetBSD libm, libc and kernel. The library is partly public domain and partly BSD-style licensed.
112 lines
2.9 KiB
Groff
112 lines
2.9 KiB
Groff
.\" $NetBSD: ilogb.3,v 1.3 2011/08/02 10:15:03 wiz Exp $
|
|
.\"
|
|
.\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi>
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd July 29, 2011
|
|
.Dt ILOGB 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm ilogb ,
|
|
.Nm ilogbf ,
|
|
.Nm ilogbl
|
|
.Nd an unbiased exponent
|
|
.Sh LIBRARY
|
|
.Lb libm
|
|
.Sh SYNOPSIS
|
|
.In math.h
|
|
.Ft int
|
|
.Fn ilogb "double x"
|
|
.Ft int
|
|
.Fn ilogbf "float x"
|
|
.Ft int
|
|
.Fn ilogbl "long double x"
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Fn ilogb ,
|
|
.Fn ilogbf ,
|
|
and
|
|
.Fn ilogbl
|
|
functions return the exponent of the non-zero real floating-point number
|
|
.Fa x
|
|
as a signed integer value.
|
|
Formally the return value is the integral part of
|
|
.Bd -ragged -offset indent
|
|
log_r |
|
|
.Va x | ,
|
|
.Ed
|
|
.Pp
|
|
where
|
|
.Fa r
|
|
is the radix of the machine's floating-point arithmetic defined by the
|
|
.Dv FLT_RADIX
|
|
constant in
|
|
.In float.h .
|
|
.Sh RETURN VALUES
|
|
As described above, upon successful completion,
|
|
the functions return the exponent.
|
|
Functionally this is the same as calling the corresponding
|
|
.Xr logb 3
|
|
function and casting the return value to
|
|
.Vt int .
|
|
.Pp
|
|
The following special cases may occur:
|
|
.Bl -enum -offset indent
|
|
.It
|
|
If
|
|
.Fa x
|
|
is zero, the value of
|
|
.Dv FP_ILOGB0
|
|
is returned and a domain error occurs.
|
|
.It
|
|
If
|
|
.Fa x
|
|
is infinite, a domain error occurs and the value of
|
|
.Dv INT_MAX
|
|
is returned.
|
|
.It
|
|
If
|
|
.Fa x
|
|
is \*(Na, a domain error is raised and the value of
|
|
.Dv FP_ILOGBNAN
|
|
is returned.
|
|
.It
|
|
If the correct value is outside the range of the return type,
|
|
a domain error occurs but an unspecified value is returned.
|
|
.El
|
|
.Sh SEE ALSO
|
|
.Xr ilog2 3 ,
|
|
.Xr logb 3 ,
|
|
.Xr math 3
|
|
.Sh STANDARDS
|
|
The described functions conform to
|
|
.St -isoC-99 .
|
|
.Sh BUGS
|
|
Neither
|
|
.Dv FP_ILOGB0
|
|
nor
|
|
.Dv FP_ILOGBNAN
|
|
is defined currently in
|
|
.Nx .
|