DEV Community

Discussion on: How to Use C Functions in Python

 
stefano1511 profile image
Stefano1511

Sure, thanks again!

Thread Thread
 
benh42 profile image
Ben Hartley

Not sure if this thread will be active again, but I found that on the c side of the program (using long long) it is accurate up to 20! . I found this by adding a printf statement in cfactorial.c . So it seems that at some point in the process of python and c communicating, the true value is lost.

Thread Thread
 
erikwhiting88 profile image
Erik

interesting. perhaps ints in C are represented differently in memory than in Python. maybe the best way is to parse the int into a char array and send it to Python as a string?

Thread Thread
 
benh42 profile image
Ben Hartley

That does sound promising because I imagine it could scale almost indefinitely if its not bound by the long or long long limits