BigDecimal\'s equals()
method compares scale too, so
new BigDecimal(\"0.2\").equals(new BigDecimal(\"0.20\")) // false
It\'s c
Use the compareTo method of BigDecimal.
BigDecimal("0.200").compareTo(new BigDecimal("0.2")) == 0; // Means they are equal.
From the JavaDoc
Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in value but have a different scale (like 2.0 and 2.00) are considered equal by this method. This method is provided in preference to individual methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=). The suggested idiom for performing these comparisons is: (x.compareTo(y)
0), where
is one of the six comparison operators.