[Python-Dev] Re: Decimal data type issues

Batista, Facundo FBatista at uniFON.com.ar
Mon Apr 19 16:08:03 EDT 2004


[Jewett, Jim J]
#- Under the current implementation:
#- 
#- 	(0, (2, 4, 0, 0, 0), -4) 
#- 
#- is not quite the same as
#- 
#- 	(0, (2, 4) -1)
#- 
#- Given this, is should be possible for the user to specify 
#- (at creation) which is desired.

It *is* posible:

>>> Decimal('2.4000')
Decimal( (0, (2, 4, 0, 0, 0), -4) )
>>> Decimal('2.4')
Decimal( (0, (2, 4), -1) )
>>>


#- I agree that the programmer should specify if they want 
#- something odd -- and that is precisely why the constructor 
#- should take an optional context argument which allows the 
#- user to specify precision.

If you construct using precision, and the precision is smaller than the
quantity of digits you provide, you'll get rounded, but if the precision is
greater than the quantity of digits you provide, you don't get filled with
zeros.


#- Given that float input may well look like string (saved to a
#- file by another program) or even an integer (C double may have 
#- more precision than C long) there is no particular reason to
#- say "context is only allowed when constructing from a float"

No. Why we should do that? 

.	Facundo



More information about the Python-Dev mailing list