bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math log() Method

❮ Math Methods

Example

System.out.println(Math.log(6));
System.out.println(Math.log(Math.E));
System.out.println(Math.log(2));
System.out.println(Math.log(1));
System.out.println(Math.log(0));
System.out.println(Math.log(-1));

Definition and Usage

The log() method returns the natural logarithm of a number.

The natural logarithm is the logarithm with base e . The value of e is approximately 2.718282 and it is available as the constant Math.E in Java.

Syntax

public static double log(double
number )

Parameter Values

ParameterDescription
numberRequired. Specifies the value to calculate the logarithm for. If the value is negative, it returns NaN (Not a Number). If the value is 0, it returns -Infinity.

Technical Details

Returns:A double value representing the natural logarithm of a number.
Java version:Any

Previous

Java Math incrementExact() Method

Next

Java Math log10() Method