This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients rhettinger, steven.daprano
Date 2009-01-01.00:38:20
SpamBayes Score 7.284521e-08
Marked as misclassified No
Message-id <>
The decimal constructor should be lossless.  The underlying spec was
designed with the notion that all numbers in decimal are exact;
operations can be lossy but the numbers themselves are exact. 
Accordingly, I recommend Decimal.from_float(f) with no qualifiers or
optional arguments.

To support the use case of wanting to round the input, I suggest a
separate method modeled on Context.create_decimal().  It can either be
an extension of the existing method or a new method like
Context.create_decimal_from_float().  I recommend the former since
rounding is already implied by the context qualifier.  Either way, the
effect would be the same as Decimal.from_float(f) + 0 in a given
context.  Per the docs:  "Creates a new Decimal instance from num but
using self as context. Unlike the Decimal constructor, the context
precision, rounding method, flags, and traps are applied to the conversion."
Date User Action Args
2009-01-01 00:38:25rhettingersetrecipients: + rhettinger, steven.daprano
2009-01-01 00:38:24rhettingersetmessageid: <>
2009-01-01 00:38:23rhettingerlinkissue4796 messages
2009-01-01 00:38:20rhettingercreate