Is there any way to write log(base 2) function?
The C language has 2 built in function -->>
1.log
which is base e.
2.log10
base 10;
But I need log function of base 2.How to calculate this.
Open the document and place the cursor at the point where you want to insert the logarithm. Type "log," followed by the subscript icon given under the "Font" category of the "Home" tab. Type the base of the logarithm in subscript; for instance, "2." Press the subscript icon again to revert to normal font.
Log base 2 is the power to which the number 2 must be raised to obtain the value of n. For any real number x, log base 2 functions are written as. x = log2 n. Which is equal to. 2x = n.
Here it is always easier to find the value of log(2) to the base 10 and use it to find the value of the logarithm of 2 on any other basis. Using properties we can find the answer through calculations, close to the actual value. 10 *log(2) = log(1024). Since the base is also 10, we get log(2) = 3*0.1.
Simple math:
log2 (x) = logy (x) / logy (2)
where y can be anything, which for standard log functions is either 10 or e.
C99 has log2
(as well as log2f
and log2l
for float and long double).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With