Java Math.round() method

The java.lang.Math.round() is used 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

Parameter

Return

  • If the argument is positive or negative number, this method will return the nearest value.
  • If the argument is not a number (NaN), this method will return Zero.
  • If the argument is positive Infinity or any value less than or equal to the value of Integer.MIN_VALUE, this method will return Integer.MIN_VALUE.
  • If the argument is negative Infinity or any value less than or equal to the value of Long.MAX_VALUE, this method will return Long.MAX_VALUE.

Example 1

Test it Now

Output:

80

Example 2

Test it Now

Output:

-84

Example 3

Test it Now

Output:

-9223372036854775808

Example 4

Test it Now

Output:

9223372036854775807

Example 5

Test it Now

Output:

0

Next TopicJava Math




Latest Courses