Calculates the signed exponent of a double precision floating-point value.
Include
<math.h>
Prototype
long double logb(long double x);
Argument
x
Return Value
Returns the exponent of x
as a signed floating-point value.
The argument is treated as being normalized if it is a subnormal floating-point
value.
Remarks
A domain error might occur if x
is 0.
Example
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main(void)
{
long double x, y;
errno = 0;
x = 13.45;
y = logbl(x);
if (errno)
perror("Error");
printf("The exponent of %Lf is %Lf\n",
x, y);
errno = 0;
x = 0.0;
y = logbl(x);
if (errno)
perror("Error");
printf("The exponent of %Lf is %Lf\n",
x, y);
errno = 0;
x = -2.0;
y = logbl(x);
if (errno)
perror("Error");
printf("The exponent of %Lf is %Lf\n",
x, y);
}
Example Output
The exponent of 13.450000 is 3.000000
The exponent of 0.000000 is -inf
The exponent of -2.000000 is 1.000000