C examples for math.h:log2
function
<cmath> <ctgmath> <math.h>
Returns the binary (base-2) logarithm of x.
long double log2l (long double x); long double log2 (long double x); double log2 (double x); float log2f (float x); double log2 (double x); float log2 (float x); double log2 (T x);
Parameter | Description |
---|---|
x | Value whose logarithm is calculated. If the argument is negative, a domain error occurs. |
The binary logarithm of x: log x base 2.
#include <stdio.h> #include <math.h> int main ()/*from w w w . ja v a 2 s. c o m*/ { double param = 1024.0; double result = log2 (param); printf ("log2 (%f) = %f.\n", param, result ); return 0; }