RE: [Python-Dev] PEP 327: Decimal Data Type
Stephen Horne writes: #- Good point. A 'DecimalExact' or similar function could perhaps be #- provided to replace the simple conversion when people have really #- thought about it and do really want it. So, making it short: When you have som rounding, it's ok to have a second parameter: Decimal(1.1, 2) == Decimal('1.1') I proposed that without the second parameter, the conversion to be exact: Decimal(1.1) == Decimal('110000000000000008881784197001252...e-51') Michael Chermside proposed to have the second parameter mandatory: avoids the problem of a newbie forgetting it, and if you want an exact conversion you can always put a very large number (e.g.: 60). If the second parameter will be mandatory, I prefer a non sense number there, for example: 0. And Stephen Horne proposed to have an explicit method to do the exact conversion, kind of: Decimal.fromFloat(1.1) == Decimal('110000000000000008881784197001252...e-51') So, we need to choose one of three ways to obtain an exact conversion: 1. Without a second parameter. 2. With a second parameter "big enough" or a special value (0? -1?) 3. With another method. Name? Thank you all! . 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.
On Mon, Feb 02, 2004, Batista, Facundo wrote:
So, we need to choose one of three ways to obtain an exact conversion:
1. Without a second parameter. 2. With a second parameter "big enough" or a special value (0? -1?) 3. With another method. Name?
Decimal.fromFloat() -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death." --GvR
participants (2)
-
Aahz
-
Batista, Facundo