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.