'equals()' called on 'BigDecimal'
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
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023