We can calculate logarithm using the Math.log10()
and the Math.log()
static method call.
package org.kodejava.math;
public class LogarithmExample {
public static void main(String[] args) {
double number1 = 1000.0d;
// Get common logarithm
double log10 = Math.log10(number1);
System.out.println("Common logarithm of " + number1 + " = " + log10);
// Get natural logarithm
double loge = Math.log(number1);
System.out.println("Natural logarithm of " + number1 + " = " + loge);
}
}
The output of the program is:
Common logarithm of 1000.0 = 3.0
Natural logarithm of 1000.0 = 6.907755278982137
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024