Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:
> 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). _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4796> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com