Use RoundingMode in Number
mpnd opened this issue · comments
Rounding may be required when a Number
is converted to a long
. Should we include RoundingMode
in Number
to specify the rounding behaviour?
Currently there is no rounding when converting Number
to long
.
decodeLong()
returns the Integer part of the number if it fits in a long, otherwise it throws an ArithmeticException.
decodeApproximateLong()
returns the lower 64 bits of the Integer part of the number.
I don't think there is a urgent need to introduce different rounding modes, as you can always get a floating point representation and do the rounding on that.
However, we should clarify the behaviour of decodeLong()
and decodeApproximateLong()
in the respective javadoc.
I agree this doesn't seem necessary.