C log2 function calculates base 2 logarithm for argument
Syntax
C log2 function has the following syntax.
float log2f(float num);
double log2(double num);
long double log2l(long double num);
Header
C log2 functions are from math.h
.
Description
C log2 functions
return the base 2
logarithm for num
.
Example
The following code calculates base 2 logarithm for argument by using C log2 functions.
#include <math.h>
#include <stdio.h>
/* w w w . ja va2 s . c o m*/
int main(void)
{
double val = 1.0;
do {
printf("%f %f\n", val, log2(val));
val++;
} while (val<11.0);
return 0;
}
The code above generates the following result.