Python is supposed to have "arbitrary precision integers," according to the answer in Python integer ranges. But this result is plainly not arbitrary precision:
$ python -c 'print("%d" % (999999999999999999999999/3))'
333333333333333327740928
According to PEP 237, bignum
is arbitrarily large (not just the size of C's long
type). And Wikipedia says Python's bignum
is arbitrary precision.
So why the incorrect result from the above line of code?
print
statement – Septicemiapython3 -c "print(999999999999999999999999 / 3)"
would show you the issue immediately (it prints a float instead of integer). – Thicket