Java math round() is an inbuilt method that is used to calculate the nearest int(or long) value of a float(or double) variable. The round() method comes handy across a large variety of programs wherever such a conversion is needed. The rounded-off value is calculated by adding 0.5 to the passed value and then taking the floor of the result.

Java Math round()

Java.lang.Math.round() is an inbuilt method that used a round of the decimal numbers to the nearest value. This method is used to return the closest long to the argument, with ties rounding to positive infinity.

Syntax

public static int round(float x)
public static long round(double x)

#java #java math round

Java Math round() Function Example
4.25 GEEK