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 May 10, 2011 .Dt ILOGB 3 .Os .Sh NAME .Nm ilogb , .Nm ilogbf .Nd an unbiased exponent .Sh LIBRARY .Lb libm .Sh SYNOPSIS n math.h .Ft int .Fn ilogb "double x" .Ft int .Fn ilogbf "float x" .Sh DESCRIPTION The .Fn ilogb and .Fn ilogbf 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 d -ragged -offset indent log_r | .Va x | , .Ed
p where .Fa r is the radix of the machine's floating-point arithmetic defined by the .Dv FLT_RADIX constant in n 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 .
p The following special cases may occur: l -enum -offset indent t If .Fa x is zero, the value of .Dv FP_ILOGB0 is returned and a domain error occurs. t If .Fa x is infinite, a domain error occurs and the value of .Dv INT_MAX is returned. t If .Fa x is \*(Na, a domain error is raised and the value of .Dv FP_ILOGBNAN is returned. t 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 . Furthermore, the .Vt long double variant of the functions is not yet supported.