python:超大整數的運算 原

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

python的超大整數是一個非常有用的東西,它的計算是非常重要的

a=pow(10,100)
b=pow(10,100)
print(a)
print(a//3)
print(a%(b//3))

結果:

10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
1

Process finished with exit code 0

-----------------------------------------------------------

a=pow(10,100)
b=pow(10,100)
print(a)
print(a//4)
print(a%(b//4))

結果:

10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0

Process finished with exit code 0

-----------------------------------------------

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章