0

Is there a way to reverse the hex() method of a float in Python? For example,

n = 1280.03125
n_hex = n.hex() 
print(n_hex)  # result--> 0x1.4002000000000p+10    

How can I convert 0x1.4002000000000p+10 back to 1280.03125? I know you can use int(num, base) to convert a number to integer but it doesn't support decimal.

0

1 Answer 1

2

Try float.fromhex(str):

>>> float.fromhex("0x1.4002000000000p+10")
1280.03125
Sign up to request clarification or add additional context in comments.

Comments