6.11.122 logbf Function
Calculates the signed exponent of a single-precision floating-point value.
Include
<math.h>
Prototype
float logbf(float x);
Argument
x
- any positive value for which to return the exponent
Return Value
Returns the exponent of x
as a signed floating-point value. If
x
is 0, is returned.
Remarks
The argument is treated as being normalized if it is a subnormal floating-point value.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main(void)
{
float x, y;
errno = 0;
x = 13.45;
y = logbf(x);
if (errno)
perror("Error");
printf("The exponent of %f is %f\n", x, y);
errno = 0;
x = 0.0;
y = logbf(x);
if (errno)
perror("Error");
printf("The exponent of %f is %f\n", x, y);
errno = 0;
x = -2.0;
y = logbf(x);
if (errno)
perror("Error");
printf("The exponent of %f is %f\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