Why is the result 0x18 instead of 0x12? : <p>The code is as follows:</p>

<pre><code>int main() {
// your code goes here
int val = 0x18;
int val1 = val&amp;0xf + ((val&gt;&gt;4)&amp;0xf)*10;
 printf("%d %d\n",val1,val1&amp;0x3f);
return 0;
}
</code></pre>

<p>I'm caught in a loop or something I can't figure it out. My handcrafted, step by step calculation places the result at 0x12 which is 18D, but I tried 2 compilers the print out was always 0x18.</p>

<p>Why is that?</p>

<p>The last step I calculated was 8+ 10 = 18?</p>
