The problem is that you can't represent 1111111111111111110.567 exactly as a double
in the first place. (You can't even represent your shortest value exactly, but the inaccuracy will increase significantly as you increase the magnitude.)
A double
only has about 17 significant digits of useful data anyway - you're trying to get 22 digits.
Use BigDecimal
if you want more precision - but be aware that this will change other things too. What kind of value are you trying to represent, anyway? Natural values (weights, distances etc) are appropriate for double
; artificial values (particularly currency values) are appropriate for BigDecimal
.