How do you enter a repeating decimal
|
04-29-2021, 01:07 PM
(This post was last modified: 04-29-2021 01:13 PM by Albert Chan.)
Post: #5
|
|||
|
|||
RE: How do you enter a repeating decimal
I had coded repeating decimal conversion in Python, long time ago.
Code: def dratio(s): >>> map(dratio, ['2.(777)', '71.23(4)', '71.234(56)']) [(2775, 999), (64111, 900), (7052222, 99000)] >>> [n/d for (n,d) in _] [2.7777777777777777, 71.234444444444449, 71.23456565656565] Code get the correct ratio, but not fully reduced. Fix is easy, if needed. >>> import fractions >>> dtoF = lambda s: fractions.Fraction(*dratio(s)) >>> map(dtoF, ['2.(777)', '71.23(4)', '71.234(56']) [Fraction(25, 9), Fraction(64111, 900), Fraction(3526111, 49500)] |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
How do you enter a repeating decimal - MullenJohn - 04-28-2021, 02:43 PM
RE: How do you enter a repeating decimal - cdmackay - 04-28-2021, 03:28 PM
RE: How do you enter a repeating decimal - Joe Horn - 04-28-2021, 05:44 PM
RE: How do you enter a repeating decimal - jonmoore - 04-29-2021, 11:07 AM
RE: How do you enter a repeating decimal - Albert Chan - 04-29-2021 01:07 PM
|
User(s) browsing this thread: 1 Guest(s)