# [Tutor] puzzled again by decimal module

Dick Moores rdm at rcblue.com
Sat Aug 19 01:37:18 CEST 2006

At 04:24 PM 8/18/2006, Luke Paireepinart wrote:
>Dick Moores wrote:
> > But here's the revised precisionFactorial.py:
> >
> > ========================
> > # 1precisionFactorial.py
> >
> > import decimal
> >
> > def d(x):
> >      return decimal.Decimal(str(x))
> >
> > def fact(n):
> >      product = 1
> >      dec_n = d(n)
> >      while dec_n > 1:
> >          product *= dec_n
> >          dec_n -= 1
> >      return product
> >
> > n = 100
> > decimal.getcontext().prec = 200
> > print fact(n)
> > ================================================
> >
> >
> 93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
> >
> > Still not exactly correct! I'm bewildered.
> >
>The results look the same to me
>why do you think they're not correct?
>what is the result supposed to be?

An integer not ending in 26 zeroes?

Dick