Skip to content

Commit

Permalink
Don't calculate pi all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
kg583 committed Nov 15, 2024
1 parent 390029d commit 761e3c4
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions tivars/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,7 @@
from .data import *


with dec.localcontext() as ctx:
ctx.prec = 16
pi, prev = 3, 0
t = dec.Decimal(3)

n, na, d, da = 1, 0, 0, 24
while pi != prev:
prev = pi

n, na = n + na, na + 8
d, da = d + da, da + 32
t = (t * n) / d
pi += t

ctx.prec = 14
pi = dec.Decimal("3.141592653589792")


def replacer(string: str, replacements: dict[str, str]) -> str:
Expand Down

0 comments on commit 761e3c4

Please sign in to comment.