]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/logb.3
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man3 / logb.3
CommitLineData
fea681da 1.\" Copyright 2004 Andries Brouwer <aeb@cwi.nl>.
cdf1aadc
MK
2.\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3.\" <mtk.manpages@gmail.com>
fea681da 4.\"
5fbde956 5.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
6.\"
7.\" Inspired by a page by Walter Harms created 2002-08-10
8.\"
4c1c5274 9.TH logb 3 (date) "Linux man-pages (unreleased)"
fea681da 10.SH NAME
cdf1aadc 11logb, logbf, logbl \- get exponent of a floating-point value
ee60e844
AC
12.SH LIBRARY
13Math library
8fc3b2cf 14.RI ( libm ", " \-lm )
fea681da 15.SH SYNOPSIS
c7db92b9 16.nf
fea681da 17.B #include <math.h>
68e4db0a 18.PP
fea681da 19.BI "double logb(double " x );
fea681da 20.BI "float logbf(float " x );
fea681da 21.BI "long double logbl(long double " x );
c7db92b9 22.fi
68e4db0a 23.PP
d39ad78f 24.RS -4
cc4615cc
MK
25Feature Test Macro Requirements for glibc (see
26.BR feature_test_macros (7)):
d39ad78f 27.RE
68e4db0a 28.PP
cdf1aadc 29.BR logb ():
9d2adbae 30.nf
5c10d2c5
MK
31 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
32 || _XOPEN_SOURCE >= 500
33.\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
9d2adbae
MK
34 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
35 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
36.fi
98c9347c 37.PP
cc4615cc
MK
38.BR logbf (),
39.BR logbl ():
9d2adbae 40.nf
5c10d2c5 41 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
9d2adbae
MK
42 || /* Since glibc 2.19: */ _DEFAULT_SOURCE
43 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
44.fi
fea681da 45.SH DESCRIPTION
cdf1aadc
MK
46These functions extract the exponent from the
47internal floating-point representation of
fea681da 48.I x
c13182ef 49and return it as a floating-point value.
cdf1aadc
MK
50The integer constant
51.BR FLT_RADIX ,
52defined in
53.IR <float.h> ,
54indicates the radix used for the system's floating-point representation.
c13182ef 55If
fea681da 56.B FLT_RADIX
cdf1aadc 57is 2,
c13182ef 58.BI logb( x )
fea681da
MK
59is equal to
60.BI floor(log2( x ))\fR,
3758f6da 61except that it is probably faster.
dd3568a1 62.PP
fea681da
MK
63If
64.I x
cdf1aadc 65is subnormal,
63aa9df0 66.BR logb ()
fea681da
MK
67returns the exponent
68.I x
69would have if it were normalized.
cdf1aadc
MK
70.SH RETURN VALUE
71On success, these functions return the exponent of
72.IR x .
847e0d88 73.PP
fea681da
MK
74If
75.I x
cdf1aadc
MK
76is a NaN,
77a NaN is returned.
847e0d88 78.PP
fea681da
MK
79If
80.I x
efe294cb 81is zero, then a pole error occurs, and the functions return
cd415e73
MK
82.RB \- HUGE_VAL ,
83.RB \- HUGE_VALF ,
cdf1aadc 84or
cd415e73 85.RB \- HUGE_VALL ,
cdf1aadc 86respectively.
847e0d88 87.PP
fea681da
MK
88If
89.I x
cdf1aadc
MK
90is negative infinity or positive infinity, then
91positive infinity is returned.
fea681da 92.SH ERRORS
cdf1aadc
MK
93See
94.BR math_error (7)
95for information on how to determine whether an error has occurred
96when calling these functions.
97.PP
98The following errors can occur:
99.TP
100Pole error: \fIx\fP is 0
101.\" .I errno
102.\" is set to
103.\" .BR ERANGE .
104A divide-by-zero floating-point exception
105.RB ( FE_DIVBYZERO )
106is raised.
107.PP
108These functions do not set
109.IR errno .
110.\" FIXME . Is it intentional that these functions do not set errno?
111.\" log(), log2(), log10() do set errno
112.\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6793
113.\"
889829be
MK
114.\" .SH HISTORY
115.\" The
116.\" .BR logb ()
117.\" function occurs in 4.3BSD.
b14d4aa5 118.\" see IEEE.3 in the 4.3BSD manual
31d47454 119.SH ATTRIBUTES
399fa11f
PH
120For an explanation of the terms used in this section, see
121.BR attributes (7).
c466875e
MK
122.ad l
123.nh
399fa11f
PH
124.TS
125allbox;
c466875e 126lbx lb lb
399fa11f
PH
127l l l.
128Interface Attribute Value
129T{
31d47454
PH
130.BR logb (),
131.BR logbf (),
31d47454 132.BR logbl ()
399fa11f
PH
133T} Thread safety MT-Safe
134.TE
c466875e
MK
135.hy
136.ad
137.sp 1
3113c7f3 138.SH STANDARDS
9a74e018 139C99, POSIX.1-2001, POSIX.1-2008.
47297adb 140.SH SEE ALSO
f0c34053
MK
141.BR ilogb (3),
142.BR log (3)