Issues with Math functions in Visual Studio versions
<pre><code>#include "string.h"
#include "math.h"

int main ()
{
    double result = (double)sqrt(2.3456F);
    unsigned char data[8]; //holds the bytes of the result

    memmove(data,&amp;result,8);
    for(int i=0;i&lt;8;i++)
        printf("%d\n",data[i]);
    return 0;
}
</code></pre>

<p>The above same code convert the sqrt() result to double and then stores in another double variable. Here the data holds the binary representation of the floating point number result.The same code when run on Visual C++ 6.0 and Visual C++ 2010 gives different results. Why is this so? </p>

<p>and one more thing is If the result had been a float then Visual C++ 6.0 and Visual C++ 2010 are giving the same value for the result.</p>

<p>Can any body sort out this??</p>

<p>Output with result variable being double::</p>

<p>with Visual C++ 6.0</p>

<p>byte representation of result variable-data::</p>

<pre><code>[0] 196 'Ä'
[1] 12 ''
[2] 25 ''
[3] 254 'þ'
[4] 42 '*'
[5] 129 ''
[6] 248 'ø'
[7] 63 '?'
</code></pre>

<p>with Visual C++ 2010</p>

<p>data::</p>

<pre><code>    [0] 0   unsigned char
    [1] 0   unsigned char
    [2] 0   unsigned char
    [3] 0   unsigned char
    [4] 43 '+'  unsigned char
    [5] 129 ''  unsigned char
    [6] 248 'ø' unsigned char
    [7] 63 '?'  unsigned char
</code></pre>

<p>Output with result variable being float::</p>

<p>with Visual C++ 6.0</p>

<pre><code>    [0] 88 'X'  
    [1] 9 ' '   
    [2] 196 'Ä' 
    [3] 63 '?'  
</code></pre>

<p>with Visual C++ 2010 </p>

<p>I got the same binary value for  result variable as above.</p>
