Bootstrap

Python支持大数运算,不用考虑溢出!

python的超大整数是一个非常有用的东西,它的计算是非常重要的。
eg1:
a=pow(10,100)
b=pow(10,100)
print(a)
print(a//3)
print(a//(b//3))

结果:

10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
3

Process finished with exit code 0
eg2:
a=pow(10,100)
b=pow(10,100)
def iprint(msg,res):
    print(msg.center(30,'*'))
    print(res)
 
iprint('原始数据',a)
iprint('a+a',a+a)
iprint('a-a',a-a)
iprint('a*10',a*10)
iprint('a//4',a//4)
iprint('a**0.5',a**0.5)

结果:

*************原始数据*************
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
*************a+a**************
20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
*************a-a**************
0
*************a*10*************
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
*************a//4*************
2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
************a**0.5************
1e+50
 
Process finished with exit code 0
;