The round() method of Java Math class returns a long or an int value that is closest to the argument and is rounded to positive infinity.


  1. public static int round(float a)
  2. public static long round(double a)


The parameters ‘a’ represents the floating –point number whose rounded value is to be determined.

Return Value:

The round() method returns the rounded value of the argument to its nearest long or int value.

Special cases are as follows:

  • The result is 0, if the argument is NaN.
  • The result is Long.MIN_VALUE, if the argument is negative infinity or any value less or equal to Long.MIN_VALUE.
  • The result is Long.MAX_VALUE, if the argument is positive infinity or any value greater or equal to Long.MAX_VALUE.

 Example 1:


Example 2:


Example 3:


Example 4:


Example 5:


Pin It on Pinterest

Share This