Is there a quick way to convert a float value to a byte wise (hex) representation in a QByteArray
?
Have done similar with memcpy()
before using arrays, but this doesn't seem to work too well with QByteArray
.
For example:
memcpy(&byteArrayData,&floatData,sizeof(float));
Can go the other way just fine using:
float *value= (float *)byteArrayData.data();
Am I just implementing this wrong or is there a better way to do it using Qt?
Thanks