- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Get the base 10 logarithm of a value in Java

To get the base 10 logarithm of value in Java, we use the java.lang.Math.log10() method. This method returns the log of value to the base 10 in the form of a double. If a number is 10n, then the result is n. If the value passed is NaN or negative, the result is NaN. If the value passed is positive infinity, then the value returned is positive infinity. When the parameter is positive zero or negative zero, then negative infinity is returned.

**Declaration** −The java.lang.Math.log10() method is declared as follows −

public static double log10(double a)

where a is a value whose base 10 logarithm is to be found.

Let us see a program to get the base 10 logarithm of a number in Java using the Math.log10() method.

## Example

import java.lang.Math; public class Example { public static void main(String[] args) { // declaring and initializing two double values double x = 300.0; double y = 100000; // printing their base 10 logarithms System.out.println("Base 10 logarithm of "+ x + " is " + Math.log10(x)); System.out.println("Base 10 logarithm of "+ y + " is " + Math.log10(y)); } }

## Output

Base 10 logarithm of 300.0 is 2.4771212547196626 Base 10 logarithm of 100000.0 is 5.0

- Related Questions & Answers
- Compute the logarithm base 10 with scimath in Python
- Return the base 10 logarithm of the input array element-wise in Numpy
- How to get Natural logarithm of 10 in JavaScript?
- How to get the natural logarithm (base E) of a number in JavaScript?
- Get natural logarithm value using Math.log in Java
- How to get base 2 logarithm of E in JavaScript?
- Return the base 2 logarithm for complex value input in Python
- How to get base 10 logarithms of E in JavaScript?
- Return the base 2 logarithm of the input array in Python
- Compute the logarithm base 2 with scimath in Python
- Compute the logarithm base n with scimath in Python
- Logarithm of the sum of exponentiations of the inputs in base-2 in Numpy
- Complement of Base 10 Integer in Python
- How to get Natural logarithm of 2 in JavaScript?
- Get the hyperbolic cosine of a given value in Java

Advertisements