Into a Java application I have a unit test that contains the following situation:
BigDecimal rendimentoLordoProvvisiorioExpected = new BigDecimal(2.85000);
BigDecimal rendimentoLordoProvvisiorioDB = null;
rendimentoLordoProvvisiorioDB = pucManager.getRendimentoLordoProvvisorio(date);
assertTrue(rendimentoLordoProvvisiorioExpected.compareTo(rendimentoLordoProvvisiorioDB) == 0);
the value of the rendimentoLordoProvvisiorioExpected variable is manually setted to 2.85000 and the obtained value rendimentoLordoProvvisiorioDB is 2.85000.
The problem is that when I do this comparision into the assertTrue() JUnit function
assertTrue(rendimentoLordoProvvisiorioExpected.compareTo(rendimentoLordoProvvisiorioDB) == 0);
it fail because the rendimentoLordoProvvisiorioExpected seems to be 2.850000000000000088817841970012523233890533447265625 and not 2.85000 (as setted).
Why? How can I modify the previous code to set the rendimentoLordoProvvisiorioExpected to the expected value 2.85000?