Message163397
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? |
|
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 | |
|