Compute base-2 logarithms.
#include <math.h> double log2(double x); float log2f(float x); long double log2l(long double x);
x
The value being computed.
These functions computes the base-2 logarithm of x, denoted as loge(1.0 + x).
The value of x must be greater than 0. Use fpclassify() to check the validity of the result returned by log1p().
For small magnitude x, these functions are more accurate than log(x+1.0). The functions return base-2 logarithm of x.
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("log2(%f) = %f\n", u, log2f(u)); return 0; } Output: log2(5.000000) = 2.321928.