Java Reference
In-Depth Information
1. If the argument is an integer, then the result is the same as the argument.
2. If the argument is a NaN, an infinity, or positive zero, or negative zero, then
the result is the same as the argument.
The method's only parameter is a value of type double.
public static double rint(double a)
Returnsadoublevaluethatisclosestinvaluetotheargumentandisaninte-
ger. If two double values that are integers are equally close to the value of
the argument, then the result is the integer value that is even. The following
are special cases:
1. If the argument is an integer, then the result is the same as the argument.
2. If the argument is NaN, or an infinity, or positive zero, or negative zero then
the result is the same as the argument.
The function's only parameter is a value of type double. Note that
rint() returns an integer variable in a double type.
public static long round(double a)
Returnstheclosestlongtotheargument.Theresultisroundedtoaninteger
by adding 1/2, taking the floor of the result, and casting the result to type
long. In other words, the result is equal to the value of the expression:
(long)Math.floor(a 0.5d)
The following are special cases:
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.
The method's only parameter is of type double. The integer result is re-
turned in a type long.
public static int round(float a)
Returns the closest int to the argument. The result is rounded to an integer
byadding1/2,takingtheflooroftheresult,andcastingtheresulttotypeint.
In other words, the result is equal to the value of the expression:
(int)Math.floor(a 0.5f)
The following are special cases:
Search WWH ::




Custom Search