Decimal printing without the exponent

Bryan belred1 at yahoo.com
Sun Nov 28 18:36:59 CET 2004


is there a way to make the Decimal class not print the exponent version of the 
decimal?


 >>> str(Decimal('1010'))
'1010'
 >>> str(Decimal((0, (1, 0, 1), 1)))
'1.01E+3'
 >>>

how do you make the 2nd example print 1010?

i know i can do this, but i thought i could make the Decimal class convert the 
string directly.

 >>> '%d' % Decimal((0, (1, 0, 1), 1))
'1010'
 >>>

i tried the to_eng_string() and to_sci_string() but that didn't work.  does 
anyone know how to do this?


thanks,

bryan



More information about the Python-list mailing list