How do I force usage of long doubles with Cython?

北城余情 提交于 2019-12-05 18:42:18
Abhinav

As was seen in the edit to the question, my system and compiler was behaving as expected by printing the correct range for long double, the relevant variable here being LDBL_MAX = 1.189731e+4932

Also, the module written with Cython was correctly giving an output of type long double. However, since this type is not natively supported in Python (see this question), the value that was returned was greater than the maximum size of double ,1.797693E+308 on my system and hence being equated to +inf + 0j. So this was not related to gcc at all, but to Python interpreting long doubles in an incorrect way.

I can hopefully get around this by working with another C module that can accept long double input types and process it further, the expected results from this sub-part is not expected to be outside the range of a double (or for that matter, even a float).

Another option might be to use libraries with Python that can support high precision and high range numbers, possibly GMPY.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!