简体   繁体   中英

Modulo operation for integers

I am new in Python. I just wonder, is there a modulo operation (%) exclusive for integers? My interest focuses into large (number of digits ~ 10^9) integers.

Appreciate any help. Erwin

The default modulo is ok for any kind of bigint. And the python3 int and python2 long are bigint by default.

If you are worrying about performance, it is also ok because python check the types of operands and call the correct version of modulo. You can call int to int mod by this way:

(10).__mod__(3)

which is just same to below except for type checking:

10 % 3

In this case, the problem is mostly the digits. 10^9 digits are not fit to design of python bigint. So it will take really long time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM