fork(4) download
  1. #(2^((2^(115-1))-1))*(2-(2^-4294967180))
  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 = 999999999999999999999999999999999999 # 指数上限を増やす
  8. s = ctx.power(2,20769187434139310514121985316880383)
  9. print(s)
  10. w = ctx.power(2,-4294967180)
  11. print(w)
  12. t = (s * 2 - s * w)
  13. print(t)
  14. #必要に応じて有効桁を調整する
  15. format_str = "{:.1e}".format(t)
  16. print(format_str)
  17.  
Success #stdin #stdout 0.06s 65624KB
stdin
Standard input is empty
stdout
999999999
6.846194358963926965312086138303944981275886936062751606916428004850139865061346646920761047717292454E+6252148403243369369507575027472120
0E-1000000098
1.369238871792785393062417227660788996255177387212550321383285600970027973012269329384152209543458491E+6252148403243369369507575027472121
1.4e+6252148403243369369507575027472121