Compute a logarithm with the floating-point representation's radix as base.
#include <math.h> double logb(double x); float logbf(float x); long double logbl(long double x);
x
The value being computed.
These functions compute the exponent of x in the target system's binary representation.
The value of x must be not be 0. Use fpclassify() to check the validity of the result returned by these functions.
This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.
#include <math.h> #include <stdio.h> int main(void) { float u = 5.0; printf("logb(%f) = %f\n", u, logbf(u)); return 0; } Output: log2(5.000000) = 2.000000