10
votes

I have data in IEEE 745 hexadecimal format: 0x1.5c28f5c28f5c3p-1

How would I convert this to a float in python? is this a standard module?

2
@Kevin: The "p" is similar to "e" but using a base of 2 instead of 10. - Ignacio Vazquez-Abrams

2 Answers

16
votes
>>> float.fromhex('0x1.5c28f5c28f5c3p-1')
0.68

It's in the standard library, float.fromhex.

7
votes