I'm unable to get log2 to work in my program.
does anyone have an idea to get this to work.
i have read the following
i get an error ofCode:#include<cmath> double logResult=0; logResult=log2(128); cout<<logResult;
log2 undeclared identifier
I'm unable to get log2 to work in my program.
does anyone have an idea to get this to work.
i have read the following
i get an error ofCode:#include<cmath> double logResult=0; logResult=log2(128); cout<<logResult;
log2 undeclared identifier
"Hence to fight and conquer in all your battles is not supreme excellence;
supreme excellence consists in breaking the enemy's resistance without fighting."
Art of War Sun Tzu
There is no log2 in the c standard. It's either log or log10. If you want to get a base two log value, you'd have to
Code:log(128.0)/log(2.0);
It is normally a good idea to check if a function exists before you attempt to use it. log2() is not a standard function in C or C++.
The only standard functions are log() which computes the natural logarithm (to base 2.71828...) and log10() which computes the logarithm to base 10.
The log of x in some arbitrary base can be computed as log(x)/log(base).