10

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?

1
  • @Kevin: The "p" is similar to "e" but using a base of 2 instead of 10. Commented Nov 30, 2015 at 15:55

2 Answers 2

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

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

Sign up to request clarification or add additional context in comments.

Comments

9

Ah ha:

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

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

1 Comment

IMO this should be combined with Ignacio's answer and accepted. This lacks code, his lacks a link to the docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.