By default, Perl converts big integer numbers to a float rather than use arbitrary precision:
$ perl -e 'print 32185864684058608501682550623 + 0'
3.21858646840586e+28
Vs Python switching automatically to an arbitrary precision long with a big integer:
>>> 32185864684058608501682550623 + 0
32185864684058608501682550623L
You can see that this is a loss of information about the long integer number in Perl (without using bignum
):
$ perl -e 'print 32185864684058608501682550623-32185864684058608501682550620'
0
Vs Python's default:
>>> 32185864684058608501682550623-32185864684058608501682550620
3L
To get the same (incorrect) result on Python, just convert the big num to a float first:
>>> float(32185864684058608501682550623) % 62
6.0
Then convert back to an int if you want an int:
>>> int(float(32185864684058608501682550623) % 62)
6
BTW: 32185864684058608501682550623 % 62
is actually 25, not 6 ;-)