Java Math log()

The log() method computes the natural logarithm (base e) of the specified value and returns it.

Example


Syntax of Math.log()

The syntax of the log() method is:

Math.log(double x)

Here, log() is a static method. Hence, we are calling the method directly using the class name Math.


log() Parameters

  • x - the value whose logarithm is to be computed

log() Return Values

  • returns the natural logarithm of x (i.e. ln a)
  • returns NaN if the argument is NaN or less than zero
  • returns positive infinity if the argument is positive infinity
  • returns negative infinity if the argument is zero

Example: Java Math.log()


Recommended Tutorial