Tag

Monetary Calculations

0 views collected around this technical thread.

macrozheng
macrozheng
Nov 29, 2023 · Backend Development

Why BigDecimal Is the Safest Choice for Money Calculations in Java

This article explains why using Java's BigDecimal for monetary values ensures precise, immutable, and correctly rounded calculations, compares it with float, double, long, and int, and provides best‑practice code examples for constructing, computing, and formatting financial numbers.

BigDecimalJavaMonetary Calculations
0 likes · 8 min read
Why BigDecimal Is the Safest Choice for Money Calculations in Java
Selected Java Interview Questions
Selected Java Interview Questions
May 30, 2020 · Backend Development

Understanding Precision Loss in Java's BigDecimal and Proper Usage

The article explains why floating‑point arithmetic in Java loses precision, demonstrates how even BigDecimal can suffer when constructed from double values, and shows the correct practice of using the BigDecimal(String) constructor together with utility methods to perform accurate monetary calculations.

BigDecimalFloating PointJava
0 likes · 9 min read
Understanding Precision Loss in Java's BigDecimal and Proper Usage