title: Python: limit on the accuracy of float
body: <p>The code gives an error because the value of "var" is very close to zero, less than 1e-80. I tried to fix this error using "Import decimal *", but it didn't really work. Is there a way to tell Python to round a number to zero when float number is very close to zero, i.e. &lt; 1e-50? Or any other way to fix this issue?<br>
  Thank you<br>
  CODE:</p>
  
  <pre><code>import math
  H=6.6260755e-27
  K=1.3807e-16
  C=2.9979E+10
  T=100.0
  x=3.07175e-05
  
  cst=2.0*H*H*(C**3.0)/(K*T*T*(x**6.0))
  a=H*C/(K*T*x)
  var=cst*math.exp(a)/((math.exp(a)-1.0)**2.0)
  print var
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>Traceback (most recent call last):
    File "test.py", line 11, in &lt;module&gt;
    var=cst*math.exp(a)/((math.exp(a)-1.0)**2.0)
  OverflowError: (34, 'Numerical result out of range')
  </code></pre>
  
  <p>To Kevin:
  The code was edited with following lines:</p>
  
  <pre><code>from decimal import *
  getcontext().prec = 7
  cst=Decimal(2.0*H*H*(C**3.0)/(K*T*T*(x**6.0)))
  a=Decimal(H*C/(K*T*x))
  </code></pre>