How to convert bytes to a 32‑bit floating-point number in Python

1 Answer

0 votes
import struct

data = b'\x41\x20\x00\x00'  # example: 32‑bit float in IEEE 754
value = struct.unpack('f', data)[0]

print(value)


'''
run:

1.1570521419930015e-41

'''

 



answered May 5 by avibootz

Related questions

1 answer 117 views
1 answer 127 views
2 answers 261 views
1 answer 128 views
4 answers 277 views
...