fork download
  1. from decimal import localcontext
  2. with localcontext() as ctx:
  3. print(ctx.Emax) # デフォルトの指数上限は999999なので、今回の計算だと足りない
  4. ctx.Emax = 9999999999 # 指数上限を増やす
  5. s = ctx.power(2,2147483647)
  6. print(s)
  7. #必要に応じて有効桁を調整する
  8. format_str = "{:.1e}".format(s)
  9. print(format_str)
  10.  
Success #stdin #stdout 0.03s 10040KB
stdin
Standard input is empty
stdout
999999
8.808065258419816766037465749E+646456992
8.8e+646456992