Skip to content
Advertisement

“OverflowError: Python int too large to convert to C long” on windows but not mac

I am running the exact same code on both windows and mac, with python 3.5 64 bit.

On windows, it looks like this:

JavaScript

However, this code works fine on my mac. Could anyone help explain why or give a solution for the code on windows? Thanks so much!

Advertisement

Answer

You’ll get that error once your numbers are greater than sys.maxsize:

JavaScript

You can confirm this by checking:

JavaScript

To take numbers with larger precision, don’t pass an int type which uses a bounded C integer behind the scenes. Use the default float:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement