Back to Intellij Community

BigDecimalEquals

java/java-impl/resources/inspectionDescriptions/BigDecimalEquals.html

2025.3-rc-2419 B
Original Source

Reports equals() calls that compare two java.math.BigDecimal numbers. This is normally a mistake, as two java.math.BigDecimal numbers are only equal if they are equal in both value and scale.

Example:

if (new BigDecimal("2.0").equals(
    new BigDecimal("2.00"))) {} // false

After the quick-fix is applied:

if (new BigDecimal("2.0").compareTo(
    new BigDecimal("2.00")) == 0) {} // true