Home >>Java Math Methods >Java Math.round() Method
The Math.round() method in Java Math is used To the nearest value, round the decimal numbers. This method is used to return to argument the closest long, with ties rounding to positive infinity.
public static int round(float x) public static long round(double x)
x= This parameter is used to a floating-point value to be rounded to an integer
It is used to returns the value of the argument rounded to the nearest int value.
public class MyClass
{
public static void main(String[] args)
{
double a = 13.89;
System.out.println(Math.round(a));
}
}
public class MyClass
{
public static void main(String[] args)
{
double a = -15.76;
System.out.println(Math.round(a));
}
}