Java Math log1p()

The syntax of the log1p() method is:

Math.log1p(double x)

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


log1p() Parameters

The log1p() method takes a single parameter.

  • x - the value whose logarithm is to be computed

log1p() Return Values

  • returns the natural logarithm of x + 1
  • returns NaN if x is NaN or less than -1
  • returns positive infinity if x is positive infinity
  • returns zero if x is zero

Example1 : Java Math.log1p()

In the above example, notice the expression,

Math.log1p(Math.pow(10, 3))

Here, Math.pow(10, 3) returns 103. To learn more, visit Java Math.pow().

Note: We have used the Math.sqrt() method to calculate the square root of -5. The square root of negative numeber is not a number.


Example 2: Math.log1p() and Math.log()


Recommended Tutorials: