really small values

Zentrader zentraders at
Fri Jul 20 00:11:40 CEST 2007

On Jul 17, 2:13 pm, "Dee Asbury" <deeasb... at> wrote:
> In multiplying a value of xe^-325 with ye^-4, Python is returning zero. How
> do I get it to give me back my tiny value?
> Thanks!
> Dee

Also, Python's decimal class allows theoretically unlimited
precision.  I have extremely limited knowledge here.  It gives the
following for 2**-325.  I have no idea if the answer is correct.
You'll have to see if gmpy or decimal works better for this.  One
piece of advice is to use whichever exclusively.  If you use a float
and then covert to either one, the result will be corrupted.
import decimal
decimal.getcontext().prec = 375      ## set precision at 375
print "2**-325 =", decimal.Decimal(str(2**-325))

2**-325 = 1.46302386084E-98

More information about the Python-list mailing list