0

From the AR Drone Developer's guide:

The number −0.8 is stored in memory as a 32- bit word whose value is BF 4CCCCD (16) , according to the IEEE-754 format. This 32-bit word can be considered as holding the 32-bit integer value −1085485875 (10).

Is there an "easy way" (built-in functions/existing modules) to do this in python ?

1 Answer 1

6

maybe not the best method, but it works.

import struct
s = struct.pack("f", -0.8)
i = struct.unpack("i", s)
print i
Sign up to request clarification or add additional context in comments.

1 Comment

I disagree as to "maybe not the best method" - it is "the one obvious way" to do it. Actually, there is another weay I'd consider "pythonic" of doing it using ctypes, but unlike the jack in @eryksun's comment, I'd use a ctype Union type.

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.