Author rhettinger
Recipients rhettinger, steven.daprano
Date 2009-01-01.00:38:20
SpamBayes Score 7.28452e-08
Marked as misclassified No
Message-id <1230770304.9.0.829539552545.issue4796@psf.upfronthosting.co.za>
In-reply-to
Content
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."
History
Date User Action Args
2009-01-01 00:38:25rhettingersetrecipients: + rhettinger, steven.daprano
2009-01-01 00:38:24rhettingersetmessageid: <1230770304.9.0.829539552545.issue4796@psf.upfronthosting.co.za>
2009-01-01 00:38:23rhettingerlinkissue4796 messages
2009-01-01 00:38:20rhettingercreate