griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256
but I would at least be able to choose how many digits it goes out to, and not have it end prematurely. Do you have any suggestions?
There is no problem to control how many digits you want with decimal module use getcontext().prec or python string formatting.
>>> from decimal import *
>>> Decimal(1) / Decimal(7)
Decimal('0.142857')
>>> getcontext().prec = 2
>>> Decimal(1) / Decimal(7)
Decimal('0.14')
>>> print Decimal(1) / Decimal(7)
0.14
>>> getcontext().prec = 7
>>> Decimal(1) / Decimal(7)
Decimal('0.1428571')
>>> '%.2f' % (Decimal(1) / Decimal(7))
'0.14'
snippsat
Practically a Posting Shark
808 posts since Aug 2008
Reputation Points: 353
Solved Threads: 294