Post Reply 
How do you enter a repeating decimal
04-28-2021, 02:43 PM
Post: #1
How do you enter a repeating decimal
Help,

Using the HP Prime how does one enter a repeating decimal such as 2.(777), i.e. 2.777...777...?

Thanks - Cheers!
Find all posts by this user
Quote this message in a reply
04-28-2021, 03:28 PM
Post: #2
RE: How do you enter a repeating decimal
(04-28-2021 02:43 PM)MullenJohn Wrote:  Help,

Using the HP Prime how does one enter a repeating decimal such as 2.(777), i.e. 2.777...777...?

Thanks - Cheers!

2 + 7/9 ? Smile

seriously, I don't know, but would be interested to hear.

Cambridge, UK
41CL/DM41X 12/15C/16C DM15/16 71B 17B/BII/bII+ 28S 42S/DM42 32SII 48GX 50g 35s 30b/WP34S Prime G2
& Casios, Rockwell 18R :)
Find all posts by this user
Quote this message in a reply
04-28-2021, 05:44 PM
Post: #3
RE: How do you enter a repeating decimal
(04-28-2021 03:28 PM)cdmackay Wrote:  
(04-28-2021 02:43 PM)MullenJohn Wrote:  Help,

Using the HP Prime how does one enter a repeating decimal such as 2.(777), i.e. 2.777...777...?

Thanks - Cheers!

2 + 7/9 ? Smile

seriously, I don't know, but would be interested to hear.

That's the best way. Just use as many 9's as there are repeating digits:
71.232323232323... = 71+23/99 (two 9's because there are two repeating digits)
71.234234234234... = 71+234/999 (three 9's because there are three repeating digits)

If the repeating digits do not begin immediately after the decimal point, then ALSO insert as many zeros after the 9's as there are non-repeating digits after the decimal point:
71.2344444444444... = 71.23 + 4/900
(One 9 because one digit is repeating; two 0's because two digits after the decimal point don't repeat)
71.2345656565656... = 71.234 + 56/99000
(two 9's because two digits repeat; three 0's because three digits after the decimal point don't repeat)

This is especially useful in CAS where the above yield exact results. In Home, it's often more efficient to simply key in the decimal approximation, since Home view is intended for approximate math anyway.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
04-29-2021, 11:07 AM
Post: #4
RE: How do you enter a repeating decimal
(04-28-2021 05:44 PM)Joe Horn Wrote:  This is especially useful in CAS where the above yield exact results. In Home, it's often more efficient to simply key in the decimal approximation, since Home view is intended for approximate math anyway.

Great tips Joe.

But this reminds me of a bugbear with the prime. The only way to change an improper fraction result to a mixed fraction in the CAS view is to use the propFrac function. The a b/c key only works with fractions in the Home view, where more often than not, you're working with approximate decimal values.

I'm not sure if my memory is playing tricks on me, but I could swear it wasn't always this way.
Find all posts by this user
Quote this message in a reply
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):
    'Return decimals (with no exponent) as ratio'
    s = s.rstrip(') \t')
    i = s.find('.')
    if i < 0: return int(s), 1  # assume integer, if no decimal point
    j = s.find('(', i+1)        # repeating decimal start
    if j < 0: return int(s[:i]+s[i+1:]), 10 ** (len(s)-i-1)
    r = 10 ** (len(s)-j-1)      # handle repeating decimals
    k = int( s[:i] + s[i+1:j] + s[j+1:] )
    return k - k//r - (k<0), (r-1) * 10 ** (j-i-1)

>>> 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)]
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)