Steven D'Aprano added the comment:

That is because of floating point rounding.

When you calculate a/23, the result is the approximate float 
2.659090889061502e+18 instead of the exact integer result 2659090889061502012. 
Converting to an int gives you a result which is too small:

py> a = 11**19
py> a - (a//23)*23  # calculate modulus with no rounding error
15
py> a - int(a/23)*23  # introduces rounding error
1395
py> a/23
2.659090889061502e+18
py> int(a/23)
2659090889061501952
py> int(a/23) - a//23
-60


By the way, are you aware of the third argument to pow()?

py> pow(11, 19, 23)
15

----------
nosy: +steven.daprano
resolution:  -> not a bug
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28021>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to