OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / logb.3
1 .\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>.
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" %%%LICENSE_START(VERBATIM)
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" %%%LICENSE_END
26 .\"
27 .\" Inspired by a page by Walter Harms created 2002-08-10
28 .\"
29 .TH LOGB 3 2014-02-28 "" "Linux Programmer's Manual"
30 .SH NAME
31 logb, logbf, logbl \- get exponent of a floating-point value
32 .SH SYNOPSIS
33 .B #include <math.h>
34 .sp
35 .BI "double logb(double " x );
36 .br
37 .BI "float logbf(float " x );
38 .br
39 .BI "long double logbl(long double " x );
40 .sp
41 Link with \fI\-lm\fP.
42 .sp
43 .in -4n
44 Feature Test Macro Requirements for glibc (see
45 .BR feature_test_macros (7)):
46 .in
47 .sp
48 .ad l
49 .BR logb ():
50 .RS 4
51 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
52 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED || _ISOC99_SOURCE ||
53 _POSIX_C_SOURCE\ >=\ 200112L;
54 .br
55 or
56 .I cc\ -std=c99
57 .RE
58 .br
59 .BR logbf (),
60 .BR logbl ():
61 .RS 4
62 _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
63 _POSIX_C_SOURCE\ >=\ 200112L;
64 .br
65 or
66 .I cc\ -std=c99
67 .RE
68 .ad b
69 .SH DESCRIPTION
70 These functions extract the exponent from the
71 internal floating-point representation of
72 .I x
73 and return it as a floating-point value.
74 The integer constant
75 .BR FLT_RADIX ,
76 defined in
77 .IR <float.h> ,
78 indicates the radix used for the system's floating-point representation.
79 If
80 .B FLT_RADIX
81 is 2,
82 .BI logb( x )
83 is equal to
84 .BI floor(log2( x ))\fR,
85 except that it is probably faster.
86 .LP
87 If
88 .I x
89 is subnormal,
90 .BR logb ()
91 returns the exponent
92 .I x
93 would have if it were normalized.
94 .SH RETURN VALUE
95 On success, these functions return the exponent of
96 .IR x .
97
98 If
99 .I x
100 is a NaN,
101 a NaN is returned.
102
103 If
104 .I x
105 is zero, then a pole error occurs, and the functions return
106 .RB - HUGE_VAL ,
107 .RB - HUGE_VALF ,
108 or
109 .RB - HUGE_VALL ,
110 respectively.
111
112 If
113 .I x
114 is negative infinity or positive infinity, then
115 positive infinity is returned.
116 .SH ERRORS
117 See
118 .BR math_error (7)
119 for information on how to determine whether an error has occurred
120 when calling these functions.
121 .PP
122 The following errors can occur:
123 .TP
124 Pole error: \fIx\fP is 0
125 .\" .I errno
126 .\" is set to
127 .\" .BR ERANGE .
128 A divide-by-zero floating-point exception
129 .RB ( FE_DIVBYZERO )
130 is raised.
131 .PP
132 These functions do not set
133 .IR errno .
134 .\" FIXME . Is it intentional that these functions do not set errno?
135 .\" log(), log2(), log10() do set errno
136 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6793
137 .\"
138 .\" .SH HISTORY
139 .\" The
140 .\" .BR logb ()
141 .\" function occurs in 4.3BSD.
142 .\" see IEEE.3 in the 4.3BSD manual
143 .SH ATTRIBUTES
144 .SS Multithreading (see pthreads(7))
145 The
146 .BR logb (),
147 .BR logbf (),
148 and
149 .BR logbl ()
150 functions are thread-safe.
151 .SH CONFORMING TO
152 C99, POSIX.1-2001.
153 .SH SEE ALSO
154 .BR ilogb (3),
155 .BR log (3)
156 .SH COLOPHON
157 This page is part of release 3.79 of the Linux
158 .I man-pages
159 project.
160 A description of the project,
161 information about reporting bugs,
162 and the latest version of this page,
163 can be found at
164 \%http://www.kernel.org/doc/man\-pages/.