Java Math rint() Method

Facebooktwitterredditpinterestlinkedinmailby feather

The rint() method of Java Math class returns the double value which is close to the specified argument and is equal to mathematical integer.

Syntax:

public static double rint(double a)

Parameters:

The parameter ‘a’ represents a double value.

Return Value:

The rint () method returns the double value that is close to a.

Special cases are as follows:

  • It returns the same result as the argument, if the argument value is equal to mathematical integer.
  • The result is same as that of argument, if the argument value is NaN or infinity or positive zero or negative zero.

 Example 1:

Output:

Example 2:

Output:

Example 3:

Output:

Example 4:

Output:

Facebooktwitterredditpinterestlinkedinmailby feather