title: Python weird addition bug
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/286061/python-decimal-place-issues-with-floats">python - decimal place issues with floats</a><br>
    <a href="https://stackoverflow.com/questions/10560832/python-float-equality-weirdness">Python float equality weirdness</a>  </p>
  </blockquote>
  
  
  
  <p>In the code below I have the variable <code>percentage</code> which is a float. I have it set up so that the if <code>number</code> reaches <code>10,000</code>, <code>percentage</code> is suppose to go up by <code>.01</code>.</p>
  
  <pre><code># Tries to find a number that when squared and 5%'ed is still a square.
  
  import math
  
  print("Script has started:\n")
  
  percentage = .1
  number = 1
  while number != -1:
      number = number + 1
      num_powered = number ** 2
      num_5per = num_powered * percentage
      num_5per_sqrt = math.sqrt(num_5per)
      num_list = list(str(num_5per_sqrt))
      dot_location = num_list.index(".")
      not_zero = 0
      for x in num_list[dot_location + 1:]:
          if x != "0":
              not_zero = 1
              break
      if not_zero == 0:
          print("*********************************")
          print("Map :",number)
          print("Safe-Area :",num_5per_sqrt)
          print("Percentage :",percentage)
          print("*********************************")
          input()
  
      if number &gt; 10000:
                number = 0
                percentage = percentage + .01
                print(percentage)
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>0.11
  0.12
  0.13
  0.14
  0.15000000000000002  # Here is where it goes crazy
  0.16000000000000003
  </code></pre>