Home >>Java Math Methods >Java Math.rint() Method
The Math.rint() method in Java Math is used to round the argument to the nearest integer in mathematics.
public static double rint(double x)
x= This parameter is used for a double value
It is used to returns closest floating-point value to x that is equal to a mathematical integer.
public class MyClass
{
public static void main(String[] args)
{
double a = 23.65;
System.out.println(Math.rint(a));
}
}
public class MyClass
{
public static void main(String[] args)
{
double a = -14.56;
System.out.println(Math.rint(a));
}
}