I have long Byte array as
Byte *GolfResult = (Byte*)calloc(40, sizeof(Byte));
Those Bytes are in Hex value.
For every four Bytes I like to convert to float. What I do is,make a four byte array and
unsigned char *fourbytearray = (unsigned char *)calloc(4, sizeof(unsigned char));
Then copy every four bytes to this fourbytearray.
fourbytearray[3] = GolfResult[0]; fourbytearray[2] = GolfResult[1]; fourbytearray[1] = GolfResult[2]; fourbytearray[0] = GolfResult[3];
Then convert to float.
float result = [[NSNumber numberWithUnsignedChar:*bytearray] floatValue];
It is waste of time and the result is not correct.
For example, I have four bytes as 0x4148e7e1. If I convert that hex value to float in this converter, I have correct result as 12.5666.
But if I convert like [[NSNumber numberWithUnsignedChar:*bytearray], the result is 65. It is wrong.
So what would be the best way to convert Byte array to float values for every four Bytes.