fork download
  1. #(max_emax)
  2. from decimal import *
  3. getcontext().prec = 100
  4. from decimal import localcontext
  5. with localcontext() as ctx:
  6. print(ctx.Emax) # デフォルトの指数上限は999999なので、今回の計算だと足りない
  7. ctx.Emax = 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 # 指数上限を増やす
  8. s = ctx.power(10,199)
  9. print(s)
  10. t = (10 ** s)
  11. print(t)
  12. #必要に応じて有効桁を調整する
  13. format_str = "{:.1e}".format(t)
  14. print(format_str)
Success #stdin #stdout 0.06s 66196KB
stdin
Standard input is empty
stdout
999999999
1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+199
1.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1.0e+10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000