fork download
  1. #(2^((2^(w-1))-1))*(2-(2^-t))
  2. #(2^((2^(115-1))-1))*(2-(2^-4294967180))
  3. from decimal import *
  4. getcontext().prec = 100
  5. from decimal import localcontext
  6. with localcontext() as ctx:
  7. print(ctx.Emax) # デフォルトの指数上限は999999なので、今回の計算だと足りない
  8. ctx.Emax = 10**10**5 # 指数上限を増やす
  9. #指数部
  10. w = 115
  11. #仮数部
  12. t = 4294967180
  13. a = ctx.power(2,(w - 1))
  14. b = ctx.power(2,(a - 1))
  15. print(b)
  16. c = t * -1
  17. d = ctx.power(2,c)
  18. print(d)
  19. e = (b * 2 - b * d)
  20. #最大値
  21. print(e)
  22. #必要に応じて有効桁を調整する
  23. format_str = "{:.1e}".format(e)
  24. print(format_str)
  25. f = e.log10()
  26. #桁数-1
  27. print(f)
  28. g = f.log10()
  29. #桁数の桁数-1
  30. print(g)
  31. h = ctx.power(2,t)
  32. i = h.log10()
  33. #有効桁数
  34. print(i)
  35.  
Success #stdin #stdout 0.13s 67300KB
stdin
Standard input is empty
stdout
999999999
6.846194358963926965312086138303944981275886936062751606916428004850139865061346646920761047717292454E+6252148403243369369507575027472120
0E-1000000098
1.369238871792785393062417227660788996255177387212550321383285600970027973012269329384152209543458491E+6252148403243369369507575027472121
1.4e+6252148403243369369507575027472121
6252148403243369369507575027472121.136479219976118776872467927501539848697645392075172640016007760340
33.79602927803953145109997858464656262695562002580878769896892674125907270351639335872189806561303658
1292913951.572341541580181637931172692108237008887846598525960137311655481242881281633951186895195090