If you use BigDecimal for floating point numbers, you may want to compare them by equals. But beware: BigDecimal.equals takes value and scale into acount, when comparing two BigDecimal values:
BigDecimal one_0 = new BigDecimal(“1.0”);
BigDecimal one_00 = new BigDecimal(“1.00”);
one_0.equals(one_00) // false!
For comparing BigDecimal values regardless of their scale you can use compareTo:
one_0.compareTo(one_00) == 0 // true
The same applies to JUnit test assertions for BigDecimal values: Using org.junit.Assert.assertEquals or org.hamcrest.Matcher.is take the scale of BigDecimal values into account. Use org.hamcrest.number.OrderingComparison.comparesEqualTo instead for comparing the values only.