The rint() is the inbuilt method of StrictMath class in Java which is used to get the double value which is closest in value to the argument and is equal to an integer. It returns the integer value which is even when the two double values that are integers are equally close to the value of the given argument. It returns the same as argument when the argument value is already equal to the integer and it returns the same as the argument when the argument is NaN or an infinity or positive zero or negative zero.
public static double rint(double num)
Parameters: The method accepts single parameter num of double type which is to be converted using this method.
Return Value: The method returns the closest floating point value that is equal to a integer.
Input: num =72.2 Output: 72.0
Below programs illustrate the rint() method:
The Integer value closest to 87.1 = 87.0 The Integer value closest to 87.1 = 87.0
The Integer value closest to -65.5 = -66.0 The Integer value closest to -65.5 = -66.0
- StrictMath log() Method In Java
- StrictMath pow() Method in Java
- StrictMath sin() Method in Java
- StrictMath tan() Method in Java
- StrictMath exp() Method in Java
- rint() in Java (Rounding to int)
- StrictMath cos() Method in Java with Examples
- StrictMath cbrt() Method in Java
- StrictMath atan() Method in Java
- StrictMath signum() Method in Java
- StrictMath nextUp() Method in Java
- StrictMath sqrt() Method in Java
- StrictMath round() method in Java
- StrictMath nextDown() Method in Java
- StrictMath nextAfter() Method in Java
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.