Search code examples
scala

Find the logarithm of a number in Scala


How do you find the base y logarithm of a number x in Scala? I have searched the scala.math library and I can't find a way. It seems to have only log10(x) and ln(x).


Solution

  • This is a maths question :)

    log<base y>(x) == log10(x)/log10(y) == ln(x)/ln(y)
    

    Random link from the web that explains this:

    http://www.purplemath.com/modules/logrules5.htm