Converting Log Base
Top  Previous  Next


If the logarithm of a different base is required, use the following formula:

logN(x) = ln(x)/ln(N)

e.g. To calculate the log10(5) use Math.log(5) / Math.log(10) (note Math.log() is ln()).



To calculate x^y (here ^ represents power operator).

x^y = e ^ (y * ln(x)) where e is the base of the natural logarithm.

e.g. To calculate 10 ^ 2 use Math.exp(2 * Math.log(10)) .
Note Math.exp() is e ^ n.

To calculate the square root of a number, use x^y where y = 1/2 or 0.5.
e.g. Math.exp(0.5 * Math.log(3)) returns the square root of 3.