[Python-Dev] Re: Decimal data type issues

Batista, Facundo FBatista at uniFON.com.ar
Tue Apr 20 11:23:05 EDT 2004


[Kevin Jacobs]

#- Thus, I would
#- like to create decimal instances that conform to those 
#- schema -- i.e., they
#- would be rounded appropriately and overflow errors generated if they
#- exceeded either the maximum precision or scale.  e.g.:
#- 
#-   Decimal('20000.001', precision=4, scale=0) === Decimal('20000')
#-   Decimal('20000.001', precision=4, scale=0) raises an 
#- overflow exception
#-   Decimal('20000.001', precision=5, scale=3) raises an 
#- overflow exception
#-   Decimal('200.001', precision=6, scale=3) === Decimal('200.001')
#-   Decimal('200.000', precision=6, scale=3) === Decimal('200') or 
#- Decimal('200.000')
#-      (depending on if precision and scale are interpreted as 
#- absolutes or
#-       maximums)
#- 
#- In order to be able to accomplish this behavior in an 
#- "external" library,
#- either the literals would have to be pre-parsed and manipulated, OR
#- an intermediate Decimal value would be created using the raw literal,
#- which would then used to detect overflows and then apply the
#- necessary rounding criteria based on the desired (maximum) scale.

I think that is better to include this functionality outside Decimal, by
using it or inheritating it (the same way I'll include all money specific
uses in other class).  Remember that Decimal is a module to implement the
Arithmetic behaviour of decimal floating point.

All other specific use cases should be outside it.


#- Hopefully this is somewhat clearer.

Very, thank you.


#- Neither.  It is well understood that operations on Decimal instances 
#- must rely on the
#- context.  The idea here is to overflow and round correctly 
#- upon instance 
#- creation without
#- going through a great deal of additional effort.

Don't know how much effort it will be. But I prefer that before bloating
Decimal. 

In the PEP I said:  "It is not the purpose of this PEP to have a data type
that can be used as Money without further effort". This is applicable to
other specific uses.

.	Facundo






. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
ADVERTENCIA  

La información contenida en este mensaje y cualquier archivo anexo al mismo,
son para uso exclusivo del destinatario y pueden contener información
confidencial o propietaria, cuya divulgación es sancionada por la ley. 

Si Ud. No es uno de los destinatarios consignados o la persona responsable
de hacer llegar este mensaje a los destinatarios consignados, no está
autorizado a divulgar, copiar, distribuir o retener información (o parte de
ella) contenida en este mensaje. Por favor notifíquenos respondiendo al
remitente, borre el mensaje original y borre las copias (impresas o grabadas
en cualquier medio magnético) que pueda haber realizado del mismo. 

Todas las opiniones contenidas en este mail son propias del autor del
mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones
Personales S.A. o alguna empresa asociada. 

Los mensajes electrónicos pueden ser alterados, motivo por el cual
Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación
cualquiera sea el resultante de este mensaje. 

Muchas Gracias.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20040420/557b709f/attachment.html


More information about the Python-Dev mailing list