Tadas
18th April 2010, 15:51
Hello,
I have tried to convert HEX value to float in many ways, but without any success.
I have QByteArray Hex value "425AE78F"
according to this site http://www.h-schmidt.net/FloatApplet/IEEE754.html answer should be: 54.72613
I have managed to convert this value only to DEC
QByteArray array="425AE78F";
bool ok;
qDebug() << array.toInt(&ok,16); //returns: 1113253775
qDebug() << array.toFloat(&ok); //returns: 0
This didn't worked too.
bool ok;
QByteArray text = QByteArray::fromHex("425AE78F");
qDebug() << text.data(); //returns: BZç
qDebug() << text.toFloat(&ok); //returns: 0
I have read about QByteArray, Qstring, but didn't find the answer, I'm new to QT and byte programming. I have created server with QTCpserver and QTcpsocket, I receive binary string from device to my computer. I convert binary string to Hex using toHex() function. Now i want to decode this Hex string. "425AE78F" - represents GPS coordinate Latitude and the answer should be 54.72613.
Can you tell me, what I'm doing wrong?
I have tried to convert HEX value to float in many ways, but without any success.
I have QByteArray Hex value "425AE78F"
according to this site http://www.h-schmidt.net/FloatApplet/IEEE754.html answer should be: 54.72613
I have managed to convert this value only to DEC
QByteArray array="425AE78F";
bool ok;
qDebug() << array.toInt(&ok,16); //returns: 1113253775
qDebug() << array.toFloat(&ok); //returns: 0
This didn't worked too.
bool ok;
QByteArray text = QByteArray::fromHex("425AE78F");
qDebug() << text.data(); //returns: BZç
qDebug() << text.toFloat(&ok); //returns: 0
I have read about QByteArray, Qstring, but didn't find the answer, I'm new to QT and byte programming. I have created server with QTCpserver and QTcpsocket, I receive binary string from device to my computer. I convert binary string to Hex using toHex() function. Now i want to decode this Hex string. "425AE78F" - represents GPS coordinate Latitude and the answer should be 54.72613.
Can you tell me, what I'm doing wrong?