]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>. |
2 | .\" | |
3 | .\" Permission is granted to make and distribute verbatim copies of this | |
4 | .\" manual provided the copyright notice and this permission notice are | |
5 | .\" preserved on all copies. | |
6 | .\" | |
7 | .\" Permission is granted to copy and distribute modified versions of this | |
8 | .\" manual under the conditions for verbatim copying, provided that the | |
9 | .\" entire resulting derived work is distributed under the terms of a | |
10 | .\" permission notice identical to this one. | |
c13182ef | 11 | .\" |
fea681da MK |
12 | .\" Since the Linux kernel and libraries are constantly changing, this |
13 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
14 | .\" responsibility for errors or omissions, or for damages resulting from | |
15 | .\" the use of the information contained herein. The author(s) may not | |
16 | .\" have taken the same level of care in the production of this manual, | |
17 | .\" which is licensed free of charge, as they might when working | |
18 | .\" professionally. | |
c13182ef | 19 | .\" |
fea681da MK |
20 | .\" Formatted or processed versions of this manual, if unaccompanied by |
21 | .\" the source, must acknowledge the copyright and authors of this work. | |
22 | .\" | |
23 | .\" Inspired by a page by Walter Harms created 2002-08-10 | |
24 | .\" | |
cc4615cc | 25 | .TH LOGB 3 2007-07-26 "" "Linux Programmer's Manual" |
fea681da MK |
26 | .SH NAME |
27 | logb, logbf, logbl \- get exponent of a floating point value | |
28 | .SH SYNOPSIS | |
29 | .B #include <math.h> | |
30 | .sp | |
31 | .BI "double logb(double " x ); | |
32 | .br | |
33 | .BI "float logbf(float " x ); | |
34 | .br | |
35 | .BI "long double logbl(long double " x ); | |
36 | .sp | |
20c58d70 | 37 | Link with \fI\-lm\fP. |
cc4615cc MK |
38 | .sp |
39 | .in -4n | |
40 | Feature Test Macro Requirements for glibc (see | |
41 | .BR feature_test_macros (7)): | |
42 | .in | |
43 | .sp | |
44 | .ad l | |
45 | .BR logb (), | |
46 | .BR logbf (), | |
47 | .BR logbl (): | |
48 | _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _ISOC99_SOURCE; or | |
49 | .I cc\ -std=c99 | |
50 | .ad b | |
fea681da MK |
51 | .SH DESCRIPTION |
52 | These functions extract the exponent of | |
53 | .I x | |
c13182ef MK |
54 | and return it as a floating-point value. |
55 | If | |
fea681da | 56 | .B FLT_RADIX |
c13182ef MK |
57 | is two, |
58 | .BI logb( x ) | |
fea681da MK |
59 | is equal to |
60 | .BI floor(log2( x ))\fR, | |
3758f6da | 61 | except that it is probably faster. |
fea681da MK |
62 | .LP |
63 | If | |
64 | .I x | |
c13182ef | 65 | is de-normalized, |
63aa9df0 | 66 | .BR logb () |
fea681da MK |
67 | returns the exponent |
68 | .I x | |
69 | would have if it were normalized. | |
70 | .LP | |
71 | If | |
72 | .I x | |
2f0af33b | 73 | is zero, \-\fBHUGE_VAL\fP (resp. \-\fBHUGE_VALF\fP, \-\fBHUGE_VALL\fP) |
fea681da MK |
74 | is returned, and a pole error occurs. |
75 | If | |
76 | .I x | |
77 | is infinite, plus infinity is returned. | |
78 | If | |
79 | .I x | |
80 | is NaN, NaN is returned. | |
81 | .\" .SH "RETURN VALUE" | |
82 | .\" These functions return the exponent part of their argument. | |
83 | .SH ERRORS | |
84 | In order to check for errors, set | |
85 | .I errno | |
86 | to zero and call | |
87 | .I feclearexcept(FE_ALL_EXCEPT) | |
c13182ef MK |
88 | before calling these functions. |
89 | On return, if | |
fea681da | 90 | .I errno |
eba72288 | 91 | is non-zero or |
fea681da | 92 | .I fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) |
eba72288 | 93 | is non-zero, an error has occurred. |
fea681da MK |
94 | .LP |
95 | If an error occurs and | |
96 | .I "(math_errhandling & MATH_ERRNO)" | |
eba72288 | 97 | is non-zero, then |
bf66f9bd MK |
98 | .I errno |
99 | is set to | |
fea681da MK |
100 | .BR ERANGE . |
101 | If an error occurs and | |
102 | .I "(math_errhandling & MATH_ERREXCEPT)" | |
eba72288 | 103 | is non-zero, then the divide-by-zero floating-point exception is raised. |
fea681da MK |
104 | .LP |
105 | A pole error occurs when | |
106 | .I x | |
107 | is zero. | |
889829be MK |
108 | .\" .SH HISTORY |
109 | .\" The | |
110 | .\" .BR logb () | |
111 | .\" function occurs in 4.3BSD. | |
b14d4aa5 | 112 | .\" see IEEE.3 in the 4.3BSD manual |
fea681da | 113 | .SH "CONFORMING TO" |
68e1685c | 114 | C99 |
fea681da | 115 | .SH "SEE ALSO" |
f0c34053 MK |
116 | .BR ilogb (3), |
117 | .BR log (3) |