fork download
  1. #(2^((2^(75-1))-1))*(2-(2^-4194228))
  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 = 99999999999999999999999 # 指数上限を増やす
  8. s = ctx.power(2,18889465931478580854783)
  9. print(s)
  10. w = ctx.power(2,-4194228)
  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 65660KB
stdin
Standard input is empty
stdout
999999999
5.915876214757029242027295116950231532072338608523143382429255466347394738111511219724610498648119349E+5686295847447917703454
3.658863868756259231498638217415018002634661742796950326501343075969858174528263302984737949520228419E-1262589
1.183175242951405848405459023390046306414467721704628676485851093269478947622302243944922099729623870E+5686295847447917703455
1.2e+5686295847447917703455