PDA

View Full Version : hex QByteArray to double?



tlt
10th July 2009, 22:39
Hi,

I am trying to convert a hex array representation of a double back into a double. In .NET, this could be done with the BitConverter class, but I am having trouble doing it with a QByteArray created with hex values. Is this the correct approach, or what am I doing wrong?

<code>
bool success;
QByteArray dbl("A0A869C0471445C1");
double d = dbl.toDouble(&success);

// success = false, d=0.000000

// no problem converting decimal to double:
QByteArray dbl2("123.567");
d = dbl2.toDouble(&success);
// success = true, d = 123.567
</code>

Thanks for your input,
--tlt

nish
12th July 2009, 04:33
u should try
QByteArray::number ()