a simple question about casting integers in c++
<p>i have the following very simple code -</p>

<pre><code>int x=15000
int z=0.7*x
cout&lt;&lt;"z = "&lt;&lt;z&lt;&lt;endl;
</code></pre>

<p>i get the output</p>

<pre><code>z=10499
</code></pre>

<p>but if i change it to</p>

<pre><code>int z=0.7*15000
cout&lt;&lt;"z = "&lt;&lt;z&lt;&lt;endl;
</code></pre>

<p>outputs </p>

<pre><code>z=10500
</code></pre>

<p>i understand it has something to do with z casting the result to int
but why is it different in both cases ?</p>

<p>thanks,</p>

<p>EDIT -
i'm using ubuntu's 10.10 GCC build</p>
