The java.lang.Math.round() is a built-in math function which returns the closest long to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result after adding 1/2, and casting the result to type long.
- If the argument is NaN, the result is 0.
- If the argument is negative infinity or any value less than or equal to the value of Integer.MIN_VALUE, the result is equal to the value of Integer.MIN_VALUE.
- If the argument is positive infinity or any value greater than or equal to the value of Integer.MAX_VALUE, the result is equal to the value of Integer.MAX_VALUE.
public static int round(float val) Parameter: val - floating-point value to be rounded to an integer.
The method returns the value of the argument rounded to the nearest int value.
Example: To show working of java.lang.Math.round() function
4568 -3421 9223372036854775807
- StrictMath round() method in Java
- BigDecimal round() Method in Java
- Java.math.BigInteger.probablePrime() method in Java
- Java.math.BigInteger.modInverse() method in Java
- Math pow() method in Java with Example
- Java Math log() method with example
- Java Math exp() method with Example
- Java Math tan() method with Examples
- Java Math cos() method with Examples
- Math floorMod() Method in Java
- Java Math min() method with Examples
- Java Math getExponent() method with Example
- Java Math max() method with Examples
- Java Math hypot() method with Example
- Java Math incrementExact() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.