[issue36934] C API Function PyLong_AsDouble Returning Wrong Value

2019-05-15 Thread Farhan Sajjad
New submission from Farhan Sajjad : Found this rather obscure behavior where certain 64 bit numbers are changing (probably losing precision somewhere down the call chain) if converted from PyLong to double using the PyLong_AsDouble C API function. TO REPRODUCE: #define __SIZEOF_STRS__ 512

[issue36934] C API Function PyLong_AsDouble Returning Wrong Value

2019-05-15 Thread Farhan Sajjad
Farhan Sajjad added the comment: Thanks for your input Tim. Here is what I understand: 1. In Python 3, int can be arbitrarily large. 2. C double data type can hold very large numbers, and the number tested here is quite small compared to the max. It even fits fine in a long long int. 3. Quite

[issue36934] C API Function PyLong_AsDouble Returning Wrong Value

2019-05-15 Thread Farhan Sajjad
Farhan Sajjad added the comment: Maybe I need to go back and understand why this loss of precision is taking place for the int->float conversion, and why for certain numbers. Also, it does not work in Python 2. Please disregard the previous message. -- resolution: -> not