logb
Compute the exponent of x and return the value in floating-point format.
Interface Definition
C interface:
float logbf(float x);
double logb(double x);
long double logbl(long double x);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
Return Value
- The exponent of x is returned. The value range of single-precision y is [-150, 127] and that of double-precision y is [-1074, 1024].
- If input x is ±∞, the return value is +∞.
- If input x is ±0, the return value is -∞.
- If input x is NaN, the return value is NaN.
Dependencies
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | // typical usage double x1 = 0.0, x2 = -0.0, x3 = 0x1p-1074, x4 = 0x1p1024; float x5 = 0x1p-149f; // special handling double a = INFINITY, b = -INFINITY, c = NAN; // print result printf("logb(0.0) = %.15f\n", logb(x1)); printf("logb(-0.0) = %.15f\n", logb(x2)); printf("logb(0x1p-1074) = %.15f\n", logb(x3)); printf("logb(0x1p1024) = %.15f\n", logb(x4)); printf("logbf(0x1p-150) = %.15f\n", logbf(x5)); printf("logb(INFINITY) = %.15f\n", logb(a)); printf("logb(-INFINITY) = %.15f\n", logb(b)); printf("logb(NAN) = %.15f\n", logb(c)); /* * logb(0.0) = -inf * logb(-0.0) = -inf * logb(0x1p-1074) = -1074.000000000000000 * logb(0x1p1024) = inf * logbf(0x1p-150) = -149.000000000000000 * logb(INFINITY) = inf * logb(-INFINITY) = inf * logb(NAN) = nan * * */ |
Parent topic: Exponential and Logarithmic Functions