java.lang.Math rint(double a)

Description :

This java tutorial shows how to use the rint(double a) method of Math class under java.lang package. This method returns the double value that is closest in value to the argument and is equal to a mathematical integer. If two double values that are mathematical integers are equally close, the result is the integer value that is even.

This method in simple language is simply here to round the double method argument.

Method Syntax :

public static double rint(double a)

Parameter Input :

DataType Parameter Description
double a a double value

Method Returns :

The rint(double a) method simply returns the closest floating-point value to a that is equal to a mathematical integer.

Compatibility Version :

Requires Java 1.0 and up

Exception :

N/A

Java Code Example :

This java example source code demonstrates the use of rint(double a) method of Math class. Basically we just get the rounded value of a double variable and then print the results.

Sample Output :

Running the rint(double a) method example source code of Math class will give you the following output

Exception Scenario :

N/A

Similar Method :

  • N/A

Suggested Reading List :

References :