title: Why is -0.0 not the same as 0.0?
body: <p>I could be missing something fundamental, but consider this interpreter session<sup>1</sup>:</p>
  
  <pre><code>&gt;&gt;&gt; -0.0 is 0.0
  False
  &gt;&gt;&gt; 0.0 is 0.0
  True
  &gt;&gt;&gt; -0.0  # The sign is even retained in the output.  Why?
  -0.0
  &gt;&gt;&gt;
  </code></pre>
  
  <p>You would think that the Python interpreter would realize that <code>-0.0</code> and <code>0.0</code> are the same number.  In fact, it compares them as being equal:</p>
  
  <pre><code>&gt;&gt;&gt; -0.0 == 0.0
  True
  &gt;&gt;&gt;
  </code></pre>
  
  <p>So why is Python differentiating between the two and generating a whole new object for <code>-0.0</code>?  It doesn't do this with integers:</p>
  
  <pre><code>&gt;&gt;&gt; -0 is 0
  True
  &gt;&gt;&gt; -0  # Sign is not retained
  0
  &gt;&gt;&gt;
  </code></pre>
  
  <p>Now, I realize that floating point numbers are a huge source of problems with computers, but those problems are always with regard to their accuracy.  For example:</p>
  
  <pre><code>&gt;&gt;&gt; 1.3 + 0.1
  1.4000000000000001
  &gt;&gt;&gt;
  </code></pre>
  
  <p>But this isn't an accuracy problem, is it?  I mean, we are talking about the sign of the number here, not its decimal places.</p>
  
  <hr>
  
  <p><sup>1</sup><sub>I can reproduce this behavior in both Python 2.7 and Python 3.4, so this is not a version-specific question.</sub></p>