Man Linux: Main Page and Category List

logb, logbf, logbl - get exponent of a floating-point value

#include<math.h>doublelogb(doublex);floatlogbf(floatx);longdoublelogbl(longdoublex);Link with-lm. Feature Test Macro Requirements for glibc (seefeature_test_macros(7)):logb(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _ISOC99_SOURCE; orcc-std=c99logbf(),logbl(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; orcc-std=c99

These functions extract the exponent from the internal floating-point representation ofxand return it as a floating-point value. The integer constantFLT_RADIX, defined in<float.h>, indicates the radix used for the systemâ€™s floating-point representation. IfFLT_RADIXis 2,logb(x)is equal tofloor(log2(x)), except that it is probably faster. Ifxis subnormal,logb() returns the exponentxwould have if it were normalized.

On success, these functions return the exponent ofx. Ifxis a NaN, a NaN is returned. Ifxis zero, then a pole error occurs, and the functions return -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively. Ifxis negative infinity or positive infinity, then positive infinity is returned.

Seemath_error(7) for information on how to determine whether an error has occurred when calling these functions. The following errors can occur: Pole error:xis 0 A divide-by-zero floating-point exception (FE_DIVBYZERO) is raised. These functions do not seterrno.

C99, POSIX.1-2001.

ilogb(3),log(3)

This page is part of release 3.24 of the Linuxman-pagesproject. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. 2008-08-05