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 mark.dickinson, rhettinger, steven.daprano
Date 2009-01-02.20:44:13
SpamBayes Score 4.269549e-05
Marked as misclassified No
Message-id <>
> once you've converted your float to Decimal it's trivial 
> to round it to whatever precision you feel like, so #2 
> seems unnecessary to me.

Agree with Mark on how to control rounding.  The DecimalWay(tm) is that
used by Context.create_decimal().  A second argument is problematic for
two reasons.  First, it demands that some rounding take place but
doesn't let you control the rounding method or signal an Inexact
conversion -- you need a context for that.  Second, the API for decimal
is already somewhat complex and we don't want to make it worse by
introducing a new variant with a second argument that has no parallel
elsewhere in the API.

Also agree with Mark regarding Decimal.from_float() which needs to be
lossless and exact.  It parallels fractions.from_float() which does the
same thing for rationals.

The DecimalWay(tm) is to have Decimal constructors be exact and to use
Context based constructors when rounding is desired.

I'll submit a patch to this effect (unless someone beats me to it).
Date User Action Args
2009-01-02 20:44:15rhettingersetrecipients: + rhettinger, mark.dickinson, steven.daprano
2009-01-02 20:44:15rhettingersetmessageid: <>
2009-01-02 20:44:14rhettingerlinkissue4796 messages
2009-01-02 20:44:13rhettingercreate