Using log base 10 in a formula in Java

后端 未结 5 501
遥遥无期
遥遥无期 2021-01-07 16:18

I\'m trying to write a Java program that can take values and put them into a formula involving log base 10.

How can I calculate log10 in Java?

5条回答
  •  借酒劲吻你
    2021-01-07 17:04

    It looks like Java actually has a log10 function:

    Math.log10(x)
    

    Otherwise, just use math:

    Math.log(x) / Math.log(10)
    

    http://docs.oracle.com/javase/7/docs/api/java/lang/Math.html

提交回复
热议问题