Using log base 10 in a formula in Java

后端 未结 5 526
遥遥无期
遥遥无期 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:18

    Math.log10(x)
    

    suffices for floating-point numbers.

    If you need integer log base 10, and you can use third-party libraries, Guava provides IntMath.log10(int, RoundingMode). (Disclosure: I contribute to Guava.)

提交回复
热议问题