Currently I'm learning about C types. I have a piece of C code. It is not the whole code, but I think the rest is not relevant to share. The sin and cos function are defined above in the original code.
C:
double tan(f) double f;
{
return sin(f)/cos(f);
Python:
import ctypes
testlib = ctypes.CDLL('./testlib.so')
testlib.tan.argtypes = ctypes.c_double
teslib.tan.restype = ctypes.c_double
print(testlib.tan(2))
First I didn't use the lines:
testlib.tan.argtypes = ctypes.c_double
teslib.tan.restype = ctypes.c_double
I got an output, but the ouput was 0. I thought that the double value was downcasted to an int.
What I want to achieve is that I send an double from python to C, and C will return me a double.
I'm already familiar with this documentation, but I didn't manage to find the right answer: https://docs.python.org/3/library/ctypes.html
Question: How should I modify my code to get the good output?
Ter