The two terminating numbers in question are 0.3333331901677568 and 1.0000004294967296. When multiplied in base 10, they result in the terminating number 0.33333333333327184418642096816128. The problem arises when they are multiplied in base 4294967295.
As you can see, both 0.3333331901677568 and 1.0000004294967296 terminate when expressed in base 4294967295 according to wolfram alpha:
http://www.wolframalpha.com/input/?i=0.3333331901677568+in+base+4294967295
http://www.wolframalpha.com/input/?i=1.0000004294967296+in+base+4294967295
However, the product does seem to repeat:
http://www.wolframalpha.com/input/?i=0.3333331901677568*1.0000004294967296+in+base+4294967295
I was under the impression that two terminating numbers could not result in a repeating decimal when multiplied. Can someone explain this?
Multiply 2 terminating numbers and get a repeating decimal?
Moderators: gmalivuk, Moderators General, Prelates
Re: Multiply 2 terminating numbers and get a repeating decim
If the set of prime factors of the denominator in your base is a subset of the prime factors of the base (without repetition), the decimal expansion will terminate; otherwise it will repeat.
a*b = 7761021455127555974443/23283064365386962890625
23283064365386962890625 = 5^32 > the fraction will terminate in base 10 (5*2), as well as in base 4294967295 (3*5*17*257*65537).
a*b = 7761021455127555974443/23283064365386962890625
23283064365386962890625 = 5^32 > the fraction will terminate in base 10 (5*2), as well as in base 4294967295 (3*5*17*257*65537).
Re: Multiply 2 terminating numbers and get a repeating decim
If you have two numbers a and b that have a terminating nary expansion, then so does their product. The quick way to see this is to multiply a and b by a suitably large power of the base so that they become integers, then product them to get an integer, obviously. Dividing by the (square of the) suitably large power of the base again gets us our original product, and since dividing by the base is just shifting the decimal (nimal?) point, we must have a terminating nary expansion for ab.
Re: Multiply 2 terminating numbers and get a repeating decim
Okay, so is wolfram alpha doing the multiplication/base conversion incorrectly, or does the number just repeat for an absurdly long time before terminating?
 gmalivuk
 GNU Terry Pratchett
 Posts: 26739
 Joined: Wed Feb 28, 2007 6:02 pm UTC
 Location: Here and There
 Contact:
Re: Multiply 2 terminating numbers and get a repeating decim
Something that doesn't repeat in one base could definitely repeat in another. What you've done is multiply those numbers in base10 and then converted the result to that other base.
Onetenth in binary is 0.00011001100110011...
Onetenth in binary is 0.00011001100110011...
Re: Multiply 2 terminating numbers and get a repeating decim
sgfw wrote:The two terminating numbers in question are 0.3333331901677568 and 1.0000004294967296. When multiplied in base 10, they result in the terminating number 0.33333333333327184418642096816128. The problem arises when they are multiplied in base 4294967295.
As you can see, both 0.3333331901677568 and 1.0000004294967296 terminate when expressed in base 4294967295 according to wolfram alpha:
http://www.wolframalpha.com/input/?i=0.3333331901677568+in+base+4294967295
http://www.wolframalpha.com/input/?i=1.0000004294967296+in+base+4294967295
However, the product does seem to repeat:
http://www.wolframalpha.com/input/?i=0.3333331901677568*1.0000004294967296+in+base+4294967295
I was under the impression that two terminating numbers could not result in a repeating decimal when multiplied. Can someone explain this?
Wolfram Alpha got the product wrong.
The first two numbers definitely terminate. The numerators of 3333331901677568/10^16 and 10000004294967296/10^16 are cleverly chosen to be multiples of 2^16, so the denominators reduce to 5^16. Therefore they each must terminate after 16 'digits' in base 4294967295, and Wolfram Alpha agrees. Their product therefore must terminate after 32 'digits'.
The product in decimal is in fact equal to
59923104 0489375583 4627910319 4669703951 6481588818 8759571507 3098603836 9977660312 9171702690 0896459477 3671772763 4626966616 4500201855 4522846076 7227016700 9339066513 3424483123 4208379606 0883933410 7307608599 7036088895 0008550700 1766322682 7995438715 1874410277 5241682839 6645097508 3122212717 0678108623 7956579833 2125850283
divided by 4294967295^32.
ETA:
Wolfram gets it right if your inputs are written as rationals rather than decimal notation:
http://www.wolframalpha.com/input/?i=%283333331901677568%2F10%5e16*10000004294967296%2F10%5e16%29+in+base+4294967295
ETA2:
Actually, Wolfram gets the original numbers wrong too, even though these wrong versions also terminate. It must simply be that floating point numbers have less than 16 digits precision.

 Posts: 74
 Joined: Sun Dec 02, 2012 8:10 am UTC
 Location: Location Location
Re: Multiply 2 terminating numbers and get a repeating decim
A number terminates in base b if and only if it can be written as x/y, where x is any integer and y is an integer such that all the prime factors of y are prime factors of b (For example, in base 10 this is pretty clear. Divide a terminating number by 2 or 5, for example, and the result clearly won't go on forever).
So if you have two numbers that terminate in base b, call them p and q, then p = x_{1}/y_{1} and q = x_{2}/y_{2}, with the x's and y's following above. If y_{1} and y_{2} both contain only prime factors found in b, then y_{1}*y_{2} certainly does as well, so p*q satisfies above, so it doesn't terminate.
So if you have two numbers that terminate in base b, call them p and q, then p = x_{1}/y_{1} and q = x_{2}/y_{2}, with the x's and y's following above. If y_{1} and y_{2} both contain only prime factors found in b, then y_{1}*y_{2} certainly does as well, so p*q satisfies above, so it doesn't terminate.
I put the "fun" in "mathematics".
And then I took it back out.
And then I took it back out.
Who is online
Users browsing this forum: No registered users and 9 guests