Java Math log() Method

Facebooktwitterredditpinterestlinkedinmailby feather

The log() method of Math class returns the natural logarithmic value for the specified double argument.

Syntax:

public static double log(double a)

Parameters:

The parameter ‘a’ represents the value.

Return Value:

The log() method returns the natural base e logarithm of a( ln a).

Special cases of the log() method are as follows:

  • It returns NaN , if the argument is NaN or less than zero.
  • It returns positive infinity, if the argument passed is positive infinite.
  • It returns negative infinity, if the argument passed is positive zero or negative zero.

Example 1:

Output:

Log value  : 2.302585092994046

Example 2:

Output:

Example 3:

Output:

Example 4:

Output:

Facebooktwitterredditpinterestlinkedinmailby feather