double 값을 허용하는 BigDecimal 생성자 호출을 보고합니다.
These constructors produce BigDecimal that is equal to the supplied double value.
However, because doubles are encoded in the IEEE-754 64-bit double-precision binary floating-point format, the exact value can be unexpected.
For example, new BigDecimal(0.1) yields a BigDecimal object with value
0.1000000000000000055511151231257827021181583404541015625,
which is the nearest number to 0.1 representable as a double.
To get a BigDecimal that contains the expected value 0.1,
use either new BigDecimal("0.1") or BigDecimal.valueOf(0.1).
예:
class Constructor {
void foo() {
new BigDecimal(0.1);
}
}
빠른 수정을 적용한 후:
class Constructor {
void foo() {
new BigDecimal("0.1");
}
}