Message163397
| Author |
joncle |
| Recipients |
joncle |
| Date |
2012年06月22日.11:51:51 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1340365912.14.0.935631231431.issue15136@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I'm not a numeric expert but I was looking at a post on S/O which related to converting a Fraction to a certain amount of decimal places. I've had a hunt on the tracker but couldn't find anything relevant, but if I've missed it, I apologise.
# F=Fraction, D=Decimal classes
If I try num = D( F(5, 7) )
I get: TypeError: Cannot convert Fraction(5, 7) to Decimal
So I do:
>>> D(f.numerator) / D(f.denominator)
Decimal('0.7142857142857142857142857143')
Which I think is the correct result?
I guess my question is - should Decimal do this implicitly for Fraction? |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年06月22日 11:51:52 | joncle | set | recipients:
+ joncle |
| 2012年06月22日 11:51:52 | joncle | set | messageid: <1340365912.14.0.935631231431.issue15136@psf.upfronthosting.co.za> |
| 2012年06月22日 11:51:51 | joncle | link | issue15136 messages |
| 2012年06月22日 11:51:51 | joncle | create |
|