Using log base 10 in a formula in Java
问题 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 log 10 in Java? 回答1: 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 回答2: 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,