logb, logbf, logbl, _logb, _logbf

Extracts the exponent value of a floating-point argument.

Syntax

double logb(
   double x
);
float logb(
   float x
); // C++ only
long double logb(
   long double x
); // C++ only
float logbf(
   float x
);
long double logbl(
   long double x
);
double _logb(
   double x
);
float _logbf(
   float x
);
#define logb(X) // Requires C11 or higher

Parameters

x
A floating-point value.

Return value

logb returns the unbiased exponent value of x as a signed integer represented as a floating-point value.

Remarks

The logb functions extract the exponential value of the floating-point argument x, as though x were represented with infinite range. If the argument x is denormalized, it's treated as if it were normalized.

Because C++ allows overloading, you can call overloads of logb that take and return float or long double values. In a C program, unless you're using the <tgmath.h> macro to call this function, logb always takes and returns a double.

If you use the logb macro from <tgmath.h>, the type of the argument determines which version of the function is selected. See Type-generic math for details.

Input SEH exception _matherr exception
± QNaN, IND None _DOMAIN
± 0 ZERODIVIDE _SING

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

Routine Required header
_logb <float.h>
logb, logbf, logbl, _logbf <math.h>
logb macro <tgmath.h>

For more compatibility information, see Compatibility.

Libraries

All versions of the C run-time libraries.

See also

Math and floating-point support
frexp