LOGB(3POSIX)
π LOGB(3POSIX) β the POSIX Programmer's Manual glow-up π
okay bestie, we're diving into LOGB(3POSIX), straight out of the POSIX Programmer's Manual. buckle up, it's math o'clock π
πΈ PROLOG πΈ
This manual page is part of the POSIX Programmer's Manual. Heads up though β the Linux implementation of this interface may be different (so like, go check the matching Linux manual page for the tea β), or honestly the interface might not even be implemented on Linux at all. π
β¨ NAME β¨
logb, logbf, logbl β radix-independent exponent π¦
π SYNOPSIS π
#include <math.h>
double logb(double x);
float logbf(float x);
long double logbl(long double x);
three flavors, one vibe. pick your precision, queen π
π DESCRIPTION π
Everything on this page is aligned with the ISO C standard. If anything here ever conflicts with ISO C, that's 100% not on purpose, ok? This volume of POSIX.1β2017 just defers to the ISO C standard, periodt.
So what do these functions actually do? They compute the exponent of x β which is the integral part of log<sub>r</sub> |x|, handed back as a signed floating-point value, and only for non-zero x. and r? that's the radix of the machine's floating-point arithmetic, which is literally the value of FLT_RADIX defined in the <float.h> header. iykyk π
If x is subnormal, it gets treated as though it were normalized instead. so for finite positive x:
1 <= x * FLT_RADIX-logb(x) < FLT_RADIX
and if you're the kind of app that wants to actually check for error situations? you should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. then on return, if errno is non-zero, or if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, then bestieβ¦ an error has occurred π
π RETURN VALUE π
Upon successful completion, these functions return the exponent of x. slay.
If x is Β±0, then:
logb(),logbf(), andlogbl()shall return-HUGE_VAL,-HUGE_VALF, and-HUGE_VALL, respectively.
On systems that support the IEC 60559 Floating-Point option, a pole error shall occur. Otherwise, a pole error may occur. π
If x is NaN, a NaN shall be returned.
If x is Β±Inf, +Inf shall be returned.
π₯ ERRORS π₯
These functions shall fail if:
- Pole Error β the value of
xisΒ±0.- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - If the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the divide-by-zero floating-point exception shall be raised.
- If the integer expression
These functions may fail if:
- Pole Error β the value of
xis0.- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - If the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the divide-by-zero floating-point exception shall be raised.
- If the integer expression
The following sections are informative. (translation: the required stuff is done, everything below is bonus content π«Ά)
π§ EXAMPLES π§
None. literally none. the void. empty. π
π APPLICATION USAGE π
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other β but at least one of them must be non-zero. no cap.
π RATIONALE π
None. iconic of them honestly π
β FUTURE DIRECTIONS β
None. the future is a blank canvas bestie π¦
π SEE ALSO π
feclearexcept()fetestexcept()ilogb()scalbln()
The Base Definitions volume of POSIX.1β2017:
- Section 4.20, Treatment of Error Conditions for Mathematical Functions
<float.h><math.h>
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie π brought to you by IEEE/The Open Group, 2017 β aka the footer, aka the little signature at the bottom that says we're done here. go forth and compute those exponents, you absolute main character β¨π
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms