Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

log1p()

Example

Compute the natural logarithm of 1 plus x for various values of x.

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

Definition and Usage

The log1p() method in Java returns the natural logarithm of 1 + x for any given value of x.

This logarithm uses the base e, where e is approximately 2.718282, and is represented by the constant Math.E in Java.

Syntax

public static double log1p(double number) 

Parameter Values

Parameter

Dsecription

number

The input parameter must be greater than or equal to -1. If it’s less than -1, the method will return NaN (Not a Number).

Technical Details

Returns:

It returns a double value representing the natural logarithm of 1 + x, where x is a number.

Java Version:

1.5+