Message239498
| Author |
serhiy.storchaka |
| Recipients |
eric.smith, ezio.melotti, mark.dickinson, martin.panter, rhettinger, scoder, serhiy.storchaka, skrah, tuomas.suutari, wolma |
| Date |
2015年03月29日.16:54:25 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1427648066.0.0.368721431567.issue23602@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I think that Decimal is not needed for Fraction.__format__ (and I'm not sure that issue23602v4.patch is correct). The correct way to format Fraction as fixed-precision decimal is to use Fraction.__round__() or similar algorithm. The implementation can look like:
f = self.__round__(prec)
i = int(f)
return '%d.%0*d' % (i, prec, abs(f - i) * 10**prec) |
|