Double turn BigDecimal accuracy problems

First, enter:

Output:

Use new BigDecimal (), accuracy problems

Second, enter:

Output:

new BigDecimal (), the first will be converted to Double String, resolve

Third, enter:

Output:

Use BigDecimal.valueOf (), no accuracy problems

 

Summary: To solve the problem of progress that can occur when doing arithmetic Double, Double will be converted to BigDecimal do arithmetic, conversion method is best to use BigDecimal.valueOf ().

Released four original articles · won praise 0 · Views 72

Guess you like

Origin blog.csdn.net/my_whale/article/details/104067645