简体   繁体   中英

Converting hex string representation to float in python

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?

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

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

Ah ha:

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

https://docs.python.org/2/library/stdtypes.html#float.fromhex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM