正確な小数計算をするためのクラスです。 float や doubleでは、計算結果がズレる場合があります。 System.out.println(0.1 + 0.2);を実行すると、 と出力されます。 これはコンピュータの内部で 2進数で小数を表現するときの誤差が出るからです。 BigDecimalクラス を ...
Not all Java developers need the precision that BigDecimal offers. However, those who do usually don’t have to use BigDecimal for very long before running into the java.lang.ArithmeticException with ...