How can I do bit operation on python float value

V

valpa

I have a python float 1.2345678. I know that it is stored as a double
in C type. And I know it actually is 1010101010101 -like format. Then
I want to do some bit operation on it. How?

Sure, I want a float output when I finish the operation.
 
M

Miles

I have a python float 1.2345678. I know that it is stored as a double
in C type. And I know it actually is 1010101010101 -like format. Then
I want to do some bit operation on it. How?

Sure, I want a float output when I finish the operation.

Just for fun:
.... return ctypes.cast(ctypes.pointer(value), ctypes.POINTER(to_type))[0]
........ return cast(ctypes.c_double(x), ctypes.c_uint64)
........ return cast(ctypes.c_uint64(x), ctypes.c_double)
....2.5

-Miles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,200
Latest member
SCPKatheri

Latest Threads

Top