[issue28021] Calculating wrong modulus manually

2016-09-08 Thread Steven D'Aprano
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

[issue28021] Calculating wrong modulus manually

2016-09-08 Thread Xiang Zhang
Xiang Zhang added the comment: You should use a//b instead of int(a/b). >>> 11**19 - 11**19//23*23 15 >>> 11**19 - int(11**19/23)*23 1395 -- nosy: +xiang.zhang ___ Python tracker __

[issue28021] Calculating wrong modulus manually

2016-09-08 Thread Faisal Saleem
New submission from Faisal Saleem: Hi, when I calculate (11**19)%23 it gives me 15 but when I try to do the same operation manually it give a totally different result which is 1395. >>> 11**19 61159090448414546291 >>> (11**19)%23 15 >>> a=11**19 >>> a 61159090448414546291 >>> b=23 >>> c=int(a/