When changing BigDecimal to double, additional precision is added. Can you please suggest this for pre:
BigDickel daisy = new buggycallell (1.23456789123457E + 17); Double value = deci.doubleValue (); Println (value);
and print the value - 1.23456789123456992E17
. How is the last digit 7 converted into 6992
? Can I get the same input after passing the transition again?
There are useful ways and can help you investigate this problem:
BigDicale dc = new buggy (1.23456789123457E + 17); Double value = deci.doubleValue (); Println (value); Println (Math.nextDown (value)); Println (Math.nextUp (value));
Output is:
1.23456789123456992 A17 1.23456789123456976 A 17 1.23456789123457008E17
That's because you can see , Followed by ... 457008
followed by double number ... 456976
immediately ... 456 9 92
is done. Then BigDecimal.doubleValue ()
should be selected between the two closest numbers ... 456 9 92
and ... 457008
.
Actually you do not even need BigDecimal
for this exam:
double value = 1.23456789123457E +17; Println (value); // print 1.23456789123456992E17
No comments:
Post a Comment