]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/logb.3
Wrapped long lines, wrapped at sentence boundaries; stripped trailing
[thirdparty/man-pages.git] / man3 / logb.3
CommitLineData
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.\"
25.TH LOGB 3 2004-10-31 "" "Linux Programmer's Manual"
26.SH NAME
27logb, 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
37Link with \-lm.
38.SH DESCRIPTION
39These functions extract the exponent of
40.I x
c13182ef
MK
41and return it as a floating-point value.
42If
fea681da 43.B FLT_RADIX
c13182ef
MK
44is two,
45.BI logb( x )
fea681da
MK
46is equal to
47.BI floor(log2( x ))\fR,
48except it's probably faster.
49.LP
50If
51.I x
c13182ef 52is de-normalized,
63aa9df0 53.BR logb ()
fea681da
MK
54returns the exponent
55.I x
56would have if it were normalized.
57.LP
58If
59.I x
c65433e6 60is zero, \-HUGE_VAL (resp. \-HUGE_VALF, \-HUGE_VALL)
fea681da
MK
61is returned, and a pole error occurs.
62If
63.I x
64is infinite, plus infinity is returned.
65If
66.I x
67is NaN, NaN is returned.
68.\" .SH "RETURN VALUE"
69.\" These functions return the exponent part of their argument.
70.SH ERRORS
71In order to check for errors, set
72.I errno
73to zero and call
74.I feclearexcept(FE_ALL_EXCEPT)
c13182ef
MK
75before calling these functions.
76On return, if
fea681da
MK
77.I errno
78is non-zero or
79.I fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)
80is non-zero, an error has occurred.
81.LP
82If an error occurs and
83.I "(math_errhandling & MATH_ERRNO)"
84is non-zero, then
85.I errno is set to
86.BR ERANGE .
87If an error occurs and
88.I "(math_errhandling & MATH_ERREXCEPT)"
89is non-zero, then the divide-by-zero floating-point exception is raised.
90.LP
91A pole error occurs when
92.I x
93is zero.
94.SH HISTORY
95The
e511ffb6 96.BR logb ()
b14d4aa5
MK
97function occurs in 4.3BSD.
98.\" see IEEE.3 in the 4.3BSD manual
fea681da 99.SH "CONFORMING TO"
68e1685c 100C99
fea681da
MK
101.SH "SEE ALSO"
102.BR log (3),
103.BR ilogb (3)