I have been trying to figure this out for some time now and i get nowhere. I have two unsigned integers. This means four bytes.
3A BC 00 00
These represent a float value. I want to convert them to float using python.
I can do this with python using struct.unpack
.
Specifically:
values = [0x3A, 0xBC, 0x00, 0x00]
struct.unpack('>f', bytes(values))
Can someone explain this particular unpack
command?
I know that the >
part reverses the bits (big endian implementation). So they will be 00 00 BC 3A
.
What does f
does? According to the docs it means float... What does this mean? I tried omitting it but i got struct.error: unpack requires a buffer of 0 bytes
Finally, why the casting to bytes
happen?