python decimal library dmath.py v0.3 released

Mark H. Harris harrismh777 at gmail.com
Mon Mar 3 15:03:19 EST 2014


On Monday, March 3, 2014 11:23:13 AM UTC-6, Wolfgang Maier wrote:

> def fact(x):
>     """ fact(x)    factorial    {x} int x > 0        
>
>     return +Decimal(math.factorial(x))

> to make it return a Decimal rounded to context precision?

hi Wolfgang,  I'm not sure.  We're doing some things with very large factorials where (existentially) we want to know how many zeros are coming up and the end of the very large number (thousands of digits) and 2) what are the last significant figures (say twenty of them) that are just before the zero chain.
What I don't want is for the Decimal module to overflow (didn't know it would do that), and we don't want the number rounded in scientific notation at some number of places. We want to actually see the digits; all of them.
Python will do multiplications til the proverbial cows come home; well, as long as you don't try it recursively --- killing the recursive depth. Decimal has some limits internally which I still do not understand (and I have been looking at the doc and playing with it for hours). If I want to build a BIGNUM int in memory only the memory should limit what can be built, not some arbitrary limit inside Decimal.
Does any of this make sense?  and 2) can you help me understand the overflow in Decimal a little bit better. I know you're a busy guy, maybe you just know a link /

Thanks much.



More information about the Python-list mailing list