Returns the integer double value closest to this
.
Rounds away from zero when there is no closest integer:
(3.5).roundToDouble() == 4
and (-3.5).roundToDouble() == -4
.
If this is already an integer valued double, including -0.0
, or it is not
a finite value, the value is returned unmodified.
For the purpose of rounding, -0.0
is considered to be below 0.0
,
and -0.0
is therefore considered closer to negative numbers than 0.0
.
This means that for a value, d
in the range -0.5 < d < 0.0
,
the result is -0.0
.
Source
/**
* Returns the integer double value closest to `this`.
*
* Rounds away from zero when there is no closest integer:
* `(3.5).roundToDouble() == 4` and `(-3.5).roundToDouble() == -4`.
*
* If this is already an integer valued double, including `-0.0`, or it is not
* a finite value, the value is returned unmodified.
*
* For the purpose of rounding, `-0.0` is considered to be below `0.0`,
* and `-0.0` is therefore considered closer to negative numbers than `0.0`.
* This means that for a value, `d` in the range `-0.5 < d < 0.0`,
* the result is `-0.0`.
*/
double roundToDouble();