システム開発の現場において、消費税の計算や商品の割引処理、あるいは利息の算出など、お金に関わる処理は1円のズレも許されない非常に厳密な要件となります。 しかし、Javaのプログラムで一般的な小数計算に用いられる基本データ型(double型など)を ...
とても小さな数値(つまり、浮動小数点数や非常に小さい数値)をそのまま出力するためには、double型やBigDecimal型を使用することが考えられます。 例えば、BigDecimal型を使って非常に小さい数値を処理する場合は、次のようなコードになります import java.math ...
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 ...
This is a drop-in replacement for java.math.BigDecimal. If you have a Kotlin/JVM project, want to port it to Kotlin/Native iOS, but struggle because you are using java.math.BigDecimal and cannot find ...
In a previous blog post, I looked at the subtle handling required to handle double with BigDecimal. As I discussed in that post, using the BigDecimal(double) constructor rarely does what one would ...