C Tutorial/math.h/log2
log2
Item Value Header file math.h Declaration float log2f(float num);double log2(double num);long double log2l(long double num); Return returns the base 2 logarithm for num.
#include <math.h>
#include <stdio.h>
int main(void)
{
double val = 1.0;
do {
printf("%f %f\n", val, log2(val));
val++;
} while (val<11.0);
return 0;
}