Note that the Math.log(x) function actually gives you ln x (base e). Luckily, high school algebra comes to the rescue. If you need log base 10, use

Math.log(x)/Math.LN10

which divides ln x by ln 10.