[Python-Dev] repr(1.1)

Batista, Facundo FBatista at uniFON.com.ar
Wed Mar 31 08:11:48 EST 2004


Jewett, Jim wrote:

#- For that matter, Decimal might be a better default format for 1.1, if
#- a language were starting fresh.  It still wouldn't be 
#- perfect, though.
#- How many digits should 1.1/3 print?

That depends of your context.

If the precision in your context is set to 9 (default), it'll print:

>>> import Decimal
>>> d1 = Decimal.Decimal(1)
>>> d3 = Decimal.Decimal(3)
>>> d1 / d3
Decimal( (0, (3, 3, 3, 3, 3, 3, 3, 3, 3), -9L) )
>>> str(d1/d3)
'0.333333333'

.	Facundo



More information about the Python-Dev mailing list