Math.rint()

Signature

double rint (double a)

Domain

action, condition

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

NameTypeDescription
adoubleA double value.

Returns

TypeDescription
doubleThe closest floating-point value to a that is equal to a mathematical integer.

Cautions

none

Example


String result = String.valueOfDouble (Math.rint (2.4));

Result is: result contains: "2.0"