title: How to test BigDecimal values
body: <p>I am trying to unit test some methods producing BigDecimal outputs but I am quite confused with the varying precissio:</p>
  
  <pre><code>assertEquals(BigDecimal.valueOf(20), result);
  </code></pre>
  
  <p>I recently switched from crating BigDecimal values using constructor (<code>new BigDecimal(value)</code> to using <code>valueOf(value)</code>) and my tests are complaining:</p>
  
  <pre><code>Expected :20
  Actual   :20.00
  </code></pre>
  
  <p>Setting <code>BigDecimal.valueOf(20.00)</code> is not helping so my question is, what is the correct way to test these floating point BigDecimal instances? Most of my test cases will have zeros after the floating point.</p>