RE: [Pymoney-general] Hello and some questions.
Brought to you by:
facundobatista
From: Batista, F. <Fac...@te...> - 2005-05-16 22:12:35
|
[Darek Suchojad] #- """ #- Config Decimal: #- - prec (Config): 28 (*) #- - rounding (Config): round-half-up (*) #- ... #- (*) Those marked are the Decimal's default. #- """ #-=20 #- I understand that "Decimal" here means decimal.DefaultContext, = right? #- If so, than its default rounding type is ROUND_HALF_EVEN. Both yes. It should say Decimal, and it should say ROUND_HALF_EVEN. = It's not indispensable you to submit a bug regarding this, but it'll help me to remember to change it! Thanks anyway. #- And the last one. The PEP says that the Rounded exception will #- be off by default, but what about that case? #-=20 #-=20 #- getcontext().prec =3D 2 #-=20 #- c1 =3D Currency('5.1') #- c2 =3D Currency('5.2') #-=20 #- print c1+c2 #-=20 #- Currently it will "raise decimal.Inexact: Changed in rounding" #- exception. Is that okay? "Rounded" means that you lost some digits, but those digits are zero. = We don't want an exception there: >>> getcontext() Context(prec=3D2, rounding=3DROUND_HALF_EVEN, Emin=3D-999999999, = Emax=3D999999999, capitals=3D1, flags=3D[Inexact, Rounded], traps=3D[Inexact, Overflow, InvalidOperation, DivisionByZero]) >>> Decimal("5.0") + Decimal("5.0") Decimal("10") "Inexact" means that you lost some digits, and those digits matter: >>> Decimal("5.1") + Decimal("5.2") Traceback (most recent call last): ... Inexact: Changed in rounding . Facundo Bit=E1cora De Vuelo: http://www.taniquetil.com.ar/plog PyAr - Python Argentina: http://www.python.org/ar/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . = . . . . . . . . . . . . . . . . . . . ADVERTENCIA. La informaci=F3n contenida en este mensaje y cualquier archivo anexo al = mismo, son para uso exclusivo del destinatario y pueden contener informaci=F3n confidencial o propietaria, cuya divulgaci=F3n 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=E1 autorizado a divulgar, copiar, distribuir o retener informaci=F3n (o = parte de ella) contenida en este mensaje. Por favor notif=EDquenos respondiendo = al remitente, borre el mensaje original y borre las copias (impresas o = grabadas en cualquier medio magn=E9tico) 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=F3nica = Comunicaciones Personales S.A. o alguna empresa asociada. Los mensajes electr=F3nicos pueden ser alterados, motivo por el cual Telef=F3nica Comunicaciones Personales S.A. no aceptar=E1 ninguna = obligaci=F3n cualquiera sea el resultante de este mensaje. Muchas Gracias. |