1.\" $NetBSD: ilogb.3,v 1.4 2016/08/22 07:33:30 maya 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 August 22, 2016 28.Dt ILOGB 3 29.Os 30.Sh NAME 31.Nm ilogb , 32.Nm ilogbf , 33.Nm ilogbl 34.Nd an unbiased exponent 35.Sh LIBRARY 36.Lb libm 37.Sh SYNOPSIS 38.In math.h 39.Ft int 40.Fn ilogb "double x" 41.Ft int 42.Fn ilogbf "float x" 43.Ft int 44.Fn ilogbl "long double x" 45.Sh DESCRIPTION 46The 47.Fn ilogb , 48.Fn ilogbf , 49and 50.Fn ilogbl 51functions return the exponent of the non-zero real floating-point number 52.Fa x 53as a signed integer value. 54Formally the return value is the integral part of 55.Bd -ragged -offset indent 56log_r | 57.Va x | , 58.Ed 59.Pp 60where 61.Fa r 62is the radix of the machine's floating-point arithmetic defined by the 63.Dv FLT_RADIX 64constant in 65.In float.h . 66.Sh RETURN VALUES 67As described above, upon successful completion, 68the functions return the exponent. 69Functionally this is the same as calling the corresponding 70.Xr logb 3 71function and casting the return value to 72.Vt int . 73.Pp 74The following special cases may occur: 75.Bl -enum -offset indent 76.It 77If 78.Fa x 79is zero, the value of 80.Dv FP_ILOGB0 81is returned and a domain error occurs. 82.It 83If 84.Fa x 85is infinite, a domain error occurs and the value of 86.Dv INT_MAX 87is returned. 88.It 89If 90.Fa x 91is \*(Na, a domain error is raised and the value of 92.Dv FP_ILOGBNAN 93is returned. 94.It 95If the correct value is outside the range of the return type, 96a domain error occurs but an unspecified value is returned. 97.El 98.Sh SEE ALSO 99.Xr ilog2 3 , 100.Xr logb 3 , 101.Xr math 3 102.Sh STANDARDS 103The described functions conform to 104.St -isoC-99 . 105