fork download
  1. #(2^((2^(83-1))-1))*(2-(2^-16777132))
  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 = 9999999999999999999999999 # 指数上限を増やす
  8. s = ctx.power(2,4835703278458516698824703)
  9. print(s)
  10. w = ctx.power(2,-16777132)
  11. print(w)
  12. t = (s * 2 - s * w)
  13. print(t)
  14. #必要に応じて有効桁を調整する
  15. format_str = "{:.1e}".format(t)
  16. print(format_str)
Success #stdin #stdout 0.06s 66588KB
stdin
Standard input is empty
stdout
999999999
2.509186238937565223112441039150610763816982666042871467171631233643422072907164349105905119004028245E+1455691736946666932084498
1.063618689156158946586035152601686675985135938051432439808219850163464083512548509929573342203516479E-5050420
5.018372477875130446224882078301221527633965332085742934343262467286844145814328698211810238008056490E+1455691736946666932084498
5.0e+1455691736946666932084498