Floating point hex string back to float

Viewed 2964

I want to change the float to hex and hex to float.

So I want to get equal of the first float and end of the float.

This is what I tried, on Python 2.7; f1 = first float, h = hex string, f2 = new float value from the hex string.

f1 = 15.3
h=f1.hex() #0x1.e99999999999ap+3

How can I change the h hex string to a float again?

I've tried

f2 = int(h,16)
f2 = float(h)
f2 = h.float()

but none of those work.

I can also use Python 3.5 if that helps.

1 Answers
Related