Behavior of Python ** and % operators with big numbers

前端 未结 4 1405
一整个雨季
一整个雨季 2021-01-23 11:03

When I put in Python interpreter a ** b % c with large a (20 figures) b (4 figures) c (20 figures) I saw that Python calculates it pretty fast, almost like pow (a,b,c). I expect

4条回答
  •  遇见更好的自我
    2021-01-23 11:44

    There is no magic behind the scenes, other than Python supports arbitrary-precision integers, and is well-implemented. It really did calculate a**b, then %c.

提交回复
热议问题