Byte Array to Double Conversion fails in QT
<p>When I convert following bytes which are received from TCP communication, I get 0 in QT and 32.097133442517112 in C#.NET. How can I resolve this issue in QT?</p>

<p>C# .NET</p>

<pre><code>byte[] data = {0xbd, 0x7a, 0x5f, 0xde, 0x6e, 0x0c, 0x40, 0x40};
double value = BitConverter.ToDouble(data, 0); // value is 32.097133442517112
</code></pre>

<p>C++ QT</p>

<pre><code>QByteArray *arr = new QByteArray();
arr-&gt;append(0xbd);
arr-&gt;append(0x7a);
arr-&gt;append(0x5f);
arr-&gt;append(0xde);
arr-&gt;append(0x6e);
arr-&gt;append(0x0c);
arr-&gt;append(0x40);
arr-&gt;append(0x40);
double value = arr-&gt;toDouble(); // value is 0
</code></pre>

<p><strong>EDIT:</strong>
Following snippet seems to work ok. It gives the result as 32.0971. </p>

<pre><code>union {
    double d;
    char bytes[sizeof(double)];
} u;

u.bytes[0]=0xbd;
u.bytes[1]= 0x7a;
u.bytes[2]=0x5f;
u.bytes[3]=0xde;
u.bytes[4]=0x6e;
u.bytes[5]=0x0c;
u.bytes[6]= 0x40;
u.bytes[7]=0x40;
qDebug()&lt;&lt;u.d; // result 32.0971
</code></pre>

<p>Should I continue with this, or are there any QT side solution for that?</p>