StrictMath.round(double): This method is available in java.lang.StrictMath class of Java.
Syntax:
long java.lang.StrictMath.round(double a)
This method takes one argument of type double as its parameter. This method returns the closest long to the argument, with ties rounding to positive infinity.
Note:
1. If the argument is NaN, the result is 0.
2. If the argument is negative infinity or any value less than or equal to the value of Long.MIN_VALUE, the result is equal to the value of Long.MIN_VALUE.
3. If the argument is positive infinity or any value greater than or equal to the value of Long.MAX_VALUE, the result is equal to the value of Long.MAX_VALUE.
Parameters: One parameter is required for this method.
a: a floating-point value to be rounded to a long.
Returns: the value of the argument rounded to the nearest long value.
Exceptions: NA
Approach
Java
public class StrictMathrounddouble {public static void main(String[] args) {double a = 1818.45;System.out.println(StrictMath.round(a));}}
Output:
1818
No comments:
Post a Comment