I am new to Python. I would like to know what would be the best way to convert a c_double (from ctypes) to a float. My code is working, but I would like to know if there is a pythonic way to do it. What I currently do is:
FloatValue = float( str(d_Val)[9:( len( str(d_Val) ) )-1] )
Where d_Val
is c_double(-10.0)
, and I want to keep -10.0
Working with Python 2.7 under windows.
Use the value
property on a c_double
.
>>> ctypes.c_double(-10.0).value
-10.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With