We can calculate logarithm using the `Math.log10()`

and the `Math.log()`

static method call.

package org.kodejava.example.math; public class LogarithmExample { public static void main(String[] args) { double number1 = 1000.0d; double number2 = 999.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

### Wayan Saryada

Programmer, runner, recreational diver, currently living in the island of Bali, Indonesia. Mostly programming in Java, creating web based application with Spring Framework, Hibernate / JPA.

#### Latest posts by Wayan Saryada (see all)

- How to format LocalDate object using Jackson? - February 16, 2017
- How to pretty print JSON string using Jackson? - February 15, 2017
- How to convert java.time.LocalDate to java.util.Date? - February 14, 2017