title: How do I check if a BigDecimal is in a Set or Map in a scale independent way?
body: <p>BigDecimal's <code>equals()</code> method compares scale too, so</p>
  
  <pre><code>new BigDecimal("0.2").equals(new BigDecimal("0.20")) // false
  </code></pre>
  
  <p>It's <a href="https://stackoverflow.com/questions/14102083/why-is-bigdecimal-equals-specified-to-compare-both-value-and-scale-individually">contested</a> why it behaves like that.</p>
  
  <p>Now, suppose I have a <code>Set&lt;BigDecimal&gt;</code>, <strong>how do I check if 0.2 is in that Set, scale independent?</strong></p>
  
  <pre><code>Set&lt;BigDecimal&gt; set = new HashSet&lt;&gt;();
  set.add(new BigDecimal("0.20"));
  ...
  if (set.contains(new BigDecimal("0.2")) { // Returns false, but should return true
      ...
  }
  </code></pre>