Help on MathLog

 

How do I get log with base 2.

There are two options in mt4:

1. MathLog - which return natural log for a number

2. MathLog10 - which return log with base 10 for a value.


In my program, I need to get log with base 2. How do I do that? What line of code should i write?

 

Change of base

The logarithm log bx can be computed from the logarithms of x and b with respect to an arbitrary base k using the following formula: logb x = logk ⁡ x ÷ logk ⁡ b.

          Logarithm - Wikipedia

Therefor

double MathLog2(double x){ return MathLog(x) / MathLog(2.0); }
Reason: