Why am I not getting correct result when I calculate exponent with ^ in C++?
<p>I am using Bode's formuala to calculate distance of nth planet from sun</p>

<pre><code>dist = (4 + 3*(2^(n-2)))/10
</code></pre>

<p>If I calculate the distance this way, I get the right values:</p>

<pre><code>dist[2] = ((4 + 3*1)/10.0) ;  
dist[3] = ((4 + 3*2)/10.0) ;  
dist[4] = ((4 + 3*4)/10.0) ;
</code></pre>

<p>But doing it this way, gives me incorrect values:</p>

<pre><code>vector &lt;double&gt; dist(5);  

for (unsigned int i = 2; i &lt; 5; i++)  
{  
    dist[i] = ((4 + 3*(2^(3-2)))/10.0) ;  
}
</code></pre>

<p>Why so?</p>
