Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 5
    Decimal is not actually giving you exact answers. Commented Jan 22, 2015 at 4:28
  • 1
    Integers have infinite precision in Python e.g., math.factorial(170) is 7257415615307998967396728211129263114716991681296451376543577798900561843401706157852350749242617459511490991237838520776666022565442753025328900773207510902400430280058295603966612599658257104398558294257568966313439612262571094946806711205568880457193340212661452800000000000000000000000000000000000000000. See how you could use decimal.Decimal to compute an answer with arbitrary (but fixed) precision Commented Jan 22, 2015 at 5:14
  • FWIW, it's not that hard to calculate large numbers of decimal digits of e using integer arithmetic. See here for example code in Python and C. Commented Jan 22, 2015 at 5:48
  • @PM2Ring: it is even simpler using decimal module Commented Jan 22, 2015 at 5:59
  • @J.F.Sebastian: Oh, I wasn't suggesting my algorithm was simpler, or even faster. Just that it's not that hard to do this particular calculation with simple (fixed precision) integer arithmetic. OTOH, one nice thing about my algorithm is that you don't have to wait for the calculation to complete before it starts printing digits. Commented Jan 22, 2015 at 6:01