title: Adding and subtracting doubles are giving strange results
body: <p>So when I add or subtract in Java with Doubles, it giving me strange results. Here are some:</p>
  
  <p>If I add <code>0.0 + 5.1</code>, it gives me <code>5.1</code>. That's correct.</p>
  
  <p>If I add <code>5.1 + 0.1</code>, it gives me <code>5.199999999999</code> (The number of repeating <code>9</code>s may be off). That's wrong.</p>
  
  <p>If I subtract <code>4.8 - 0.4</code>, it gives me <code>4.39999999999995</code> (Again, the repeating <code>9</code>s may be off). That's wrong.</p>
  
  <p>At first I thought this was only the problem with adding doubles with decimal values, but I was wrong. The following worked fine:</p>
  
  <pre><code>5.1 + 0.2 = 5.3
  5.1 - 0.3 = 4.8
  </code></pre>
  
  <p>Now, the first number added is a double saved as a variable, though the second variable grabs the text from a <code>JTextField</code>. For example:</p>
  
  <pre><code>//doubleNum = 5.1 RIGHT HERE
  //The textfield has only a "0.1" in it.
  doubleNum += Double.parseDouble(textField.getText());
  //doubleNum = 5.199999999999999
  </code></pre>