1.\" $NetBSD: ilogb.3,v 1.1 2011/05/10 06:38:33 jruoho Exp $ 2.\" 3.\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi> 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25.\" POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd May 10, 2011 28.Dt ILOGB 3 29.Os 30.Sh NAME 31.Nm ilogb , 32.Nm ilogbf 33.Nd an unbiased exponent 34.Sh LIBRARY 35.Lb libm 36.Sh SYNOPSIS 37.In math.h 38.Ft int 39.Fn ilogb "double x" 40.Ft int 41.Fn ilogbf "float x" 42.Sh DESCRIPTION 43The 44.Fn ilogb 45and 46.Fn ilogbf 47functions return the exponent of the non-zero real floating-point number 48.Fa x 49as a signed integer value. 50Formally the return value is the integral part of 51.Bd -ragged -offset indent 52log_r | 53.Va x | , 54.Ed 55.Pp 56where 57.Fa r 58is the radix of the machine's floating-point arithmetic defined by the 59.Dv FLT_RADIX 60constant in 61.In float.h . 62.Sh RETURN VALUES 63As described above, upon successful completion, 64the functions return the exponent. 65Functionally this is the same as calling the corresponding 66.Xr logb 3 67function and casting the return value to 68.Vt int . 69.Pp 70The following special cases may occur: 71.Bl -enum -offset indent 72.It 73If 74.Fa x 75is zero, the value of 76.Dv FP_ILOGB0 77is returned and a domain error occurs. 78.It 79If 80.Fa x 81is infinite, a domain error occurs and the value of 82.Dv INT_MAX 83is returned. 84.It 85If 86.Fa x 87is \*(Na, a domain error is raised and the value of 88.Dv FP_ILOGBNAN 89is returned. 90.It 91If the correct value is outside the range of the return type, 92a domain error occurs but an unspecified value is returned. 93.El 94.Sh SEE ALSO 95.Xr ilog2 3 , 96.Xr logb 3 , 97.Xr math 3 98.Sh STANDARDS 99The described functions conform to 100.St -isoC-99 . 101.Sh BUGS 102Neither 103.Dv FP_ILOGB0 104nor 105.Dv FP_ILOGBNAN 106is defined currently in 107.Nx . 108Furthermore, the 109.Vt long double 110variant of the functions is not yet supported. 111