I am looking for the Python equivalent of Java’s Float.floatToBits.
I found this Python: obtain & manipulate (as integers) bit patterns of floats but does anyone know of a less complicated way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The answer that Alex Martelli gives in that question is really pretty simple — you can reduce it to:
Once you have it as an integer, you can perform any other manipulations you need to.
You can reverse the order of operations to round-trip: