Java Reference
In-Depth Information
public static double rint(double a)
Returns the double that is closest in value to a and is equal to an integer. If
two double values that are integers are equally close to the value of the ar-
gument,the result is the integer value that is even. The following are special
cases:
1. If the argument value is already equal to an integer,then the result is the
same as the argument.
2. If the argument is NaN or infinity or positive zero or negative zero,then the
result is the same as the argument.
public static int round(float a)
Returns the closest int to the argument. The result is rounded to an integer
by adding 1/2,taking the floor of the result,and casting the result to type int.
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 Integer.MIN_VALUE,the result is equal to the value of Inte-
ger.MIN_VALUE.
3. 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 Inte-
ger.MAX_VALUE.
public static long round(double a)
Returns the closest long to the argument. The result is rounded to an integer
by adding 1/2,taking the floor of the result,and casting the result to type
long. 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.
IEEE-style remainder
One method in the classes Math and StrictMath returns the remainder as de-
fined by the IEEE 754 Standard. IEEE 754 requires that implementations
must provide the add,subtract,multiply,divide,and remainder operations
for any two operands of the same or different format.
Search WWH ::




Custom Search