title: How to check if the sum of floats equals a number and accounting for Floating Point Inaccuracy
body: <p>I'm trying to check if a sum of floating point numbers adds up to 100. And of course they don't, due to floating point accuracy.</p>
  
  <p>So, what doesn't work is:</p>
  
  <pre><code>test = [99.9, 0.025, 0.025, 0.0125, 0.0125, 0.025]
  sum(test) == 100.
  </code></pre>
  
  <p>alternatively</p>
  
  <pre><code>sum(test) &gt; 99.99999 and sum(test) &lt; 100.0000001
  </code></pre>
  
  <p>works fine, but I consider it as ugly, because the limits are arbitrary. Is there a more elegant method in python to check float numbers on equality? Or at least a method to choose the limits not only arbitrary but based on the internal accuracy?</p>