Math.rint()
Signature
double rint (double a)
Description
Returns the double
value that is closest in value
to the argument and is equal to a mathematical integer. If two
double
values that are mathematical integers are
equally close, the result is the integer value that is
even. Special cases:
If the argument value is already equal to a mathematical
integer, then the result is the same as the argument.
If the argument is NaN or an infinity or positive zero or negative
zero, then the result is the same as the argument.
Parameters
Name | Type | Description |
a | double | A double value. |
Returns
Type | Description |
double | The closest floating-point value to a that is
equal to a mathematical integer. |
Example
String result = String.valueOfDouble (Math.rint (2.4));
Result is: result contains: "2.0"