6398720095c326532b060db79e3dd06d909f936d
[dragonfly.git] / lib / libm / man / ilogb.3
1 .\" $NetBSD: ilogb.3,v 1.3 2011/08/02 10:15:03 wiz 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 July 29, 2011
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
46 The
47 .Fn ilogb ,
48 .Fn ilogbf ,
49 and
50 .Fn ilogbl
51 functions return the exponent of the non-zero real floating-point number
52 .Fa x
53 as a signed integer value.
54 Formally the return value is the integral part of
55 .Bd -ragged -offset indent
56 log_r |
57 .Va x | ,
58 .Ed
59 .Pp
60 where
61 .Fa r
62 is the radix of the machine's floating-point arithmetic defined by the
63 .Dv FLT_RADIX
64 constant in
65 .In float.h .
66 .Sh RETURN VALUES
67 As described above, upon successful completion,
68 the functions return the exponent.
69 Functionally this is the same as calling the corresponding
70 .Xr logb 3
71 function and casting the return value to
72 .Vt int .
73 .Pp
74 The following special cases may occur:
75 .Bl -enum -offset indent
76 .It
77 If
78 .Fa x
79 is zero, the value of
80 .Dv FP_ILOGB0
81 is returned and a domain error occurs.
82 .It
83 If
84 .Fa x
85 is infinite, a domain error occurs and the value of
86 .Dv INT_MAX
87 is returned.
88 .It
89 If
90 .Fa x
91 is \*(Na, a domain error is raised and the value of
92 .Dv FP_ILOGBNAN
93 is returned.
94 .It
95 If the correct value is outside the range of the return type,
96 a 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
103 The described functions conform to
104 .St -isoC-99 .
105 .Sh BUGS
106 Neither
107 .Dv FP_ILOGB0
108 nor
109 .Dv FP_ILOGBNAN
110 is defined currently in
111 .Nx .