Skip to content

Instantly share code, notes, and snippets.

@ami-GS
Created January 24, 2014 14:05
Show Gist options
  • Save ami-GS/8597886 to your computer and use it in GitHub Desktop.
Save ami-GS/8597886 to your computer and use it in GitHub Desktop.
高精度の10進数演算と小数点以下の長さ決定
from decimal import *
getcontext().prec = 1000000#表示したい桁 デフォルトは28
N = 100
print (Decimal(1) + Decimal(1) / Decimal(N)) ** Decimal(N)
# or more precisely
print Decimal(1).exp()
#the length of above calculation is 101 (which include ".")
#to get numerical value, you shoulde type str(Decimal(1).exp())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment