我正在尝试从字符串中创建一个BigDecimal对象。不要问我为什么,我只是需要它!这是我的代码:
Double theDouble = new Double(".3");
System.out.println("The Double: " + theDouble.toString());
BigDecimal theBigDecimal = new BigDecimal(theDouble);
System.out.println("The Big: " + theBigDecimal.toString());
这是我获得的输出?
The Double: 0.3
The Big: 0.299999999999999988897769753748434595763683319091796875
有什么想法吗?