Logic of adding double values
<p>I was given the following question in an interview...</p>

<pre><code>Compute the following sum:
1/2 + 1/4 + 1/8 + ... + 1/1048576    
</code></pre>

<p>I was told that this was a logic question and they weren't looking for the source code, however my answer was the following...</p>

<pre><code>    private static double computeSum(){
        double x = 0.0;
        for(double i=2; i&lt;=1048576; i*=2){
            x += (1 / i);
        }
        return x;         
    }
</code></pre>

<p>What is the correct <em>logical</em> answer to this question?</p>
