September 25th, 2013, 07:29 AM

Ternary Digits
Suppose a new computer uses radix3 (ternary) logic instead of radix2 (binary) logic to represent unsigned integers.
What is the largest value that can be represented by 6 ternary digits?
September 25th, 2013, 08:26 AM

HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." 2600 Magazine, Fall 2002
Think we're being rude? Maybe you
asked a bad question or you're a
Help Vampire. Trying to argue intelligently? Please
read this.
September 26th, 2013, 02:10 AM

If I were to convert the decimal 47 to radix3, do I divide it repeatedly by 3?
September 26th, 2013, 08:31 AM

No. To convert something to another base, you must deal with powers. Each digit represents a power of the base. In decimal, the first (right most) digit is 10^0 times the value of the number. The second digit is 10^1 times the value of the digit. So in base 10:
12 = ((10^0)*2)+((10^1)*1)
For binary it's the same rule:
1101 = ((2^0)*1)+((2^1)*0)+((2^2)*1)+((2^3)*1) = 13
And finally, for trinary you'd calculate it the same way:
2101 = ((3^0)*1)+((3^1)*0)+((3^2)*1)+((3^3)*2) = 64
To get the answer in the other way, work backwards. Start with figuring out how many digits there will be. The highest number you can represent with 3 digits of trinary is 222, which (by our rules above) is equal to 26, so you need 4 digits. Now, work through those digits largesttosmallest:
3^3 times WHAT is less than or equal to 47? 1. The first digit is 1. Subtract ((3^3)*1) from your number and move on.
3^2 times WHAT is less than 20? 2. The second digit is 2.
3^1 times WHAT is less than 2? Nothing, 3 > 2. The third digit is 0.
3^0 times WHAT is less than or equal to 2. 2, obviously.
47 in trinary is 1202.
Check your work:
1202 = ((3^0)*2)+((3^1)*0)+((3^2)*2)+((3^3)*1) = 47
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." 2600 Magazine, Fall 2002
Think we're being rude? Maybe you
asked a bad question or you're a
Help Vampire. Trying to argue intelligently? Please
read this.
September 26th, 2013, 10:10 AM

Question 1:
3^6 = 729
I just want to confirm if the largest value that can be represented by 6 ternary digits is 729 or 728 (including 0)?
Question 2:
I seem to have arrived to (1202) base 3 by repeated division and taking the remainders.
Code:
http://s23.postimg.org/wm9vfhgpn/DSC_0170.jpg
We are taught the same way for binary, octal, and hex  dividing the decimal by radix until reaching 0 for the quotient then writing the remainders bottomup.
Thank you ManiacDan for your assistance.
September 26th, 2013, 10:17 AM

Sorry, I wasn't QUITE right before. The largest number represented by 6 ternary digits is ((3^6)1), much like for 6 binary digits is ((2^6)1).
Short proof, the largest possible number with 6 digits:
((3^0)*2)+((3^1)*2)+((3^2)*2)+((3^3)*2)+((3^4)*2)+((3^5)*2) = 728.
You don't "include zero" for determining the largest number. You can represent 729 numbers, the highest of which is 728.
The repeateddivision method works as well, I prefer not to do it that way because it's a bit of a cheat. You're using a trick in base10 math that happens to work out properly for base3 math. Why not just do it in base3? (It's slower my way unless you think in that base commonly or are able to do the math in your head without going crazy)
HEY! YOU! Read the New User Guide and Forum Rules
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." Benjamin Franklin
"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." 2600 Magazine, Fall 2002
Think we're being rude? Maybe you
asked a bad question or you're a
Help Vampire. Trying to argue intelligently? Please
read this.
September 27th, 2013, 03:07 AM

Like in my other thread where 2^5 = 32, the signed decimal range would be 16 to +15, which is 32 integers "including 0". I am thinking in the algebra/real number line concept, but it is good to see the mathematical proof behind it.
I tried with another odd number, radix7 and the repeated division worked well enough.
(158) base 10 = (314) base 7
If it worked on radix3 ONLY, then it is indeed sort of a "cheat" for radix3.
If it is a solution that works consistently on both odd and even bases, I guess it is better appropriated as an "alternative method" for converting decimal to any radixx.
Well, there goes my two cents.
Thank you for showing me the power method though. It will be a useful reference and good way to doublecheck things.
September 27th, 2013, 04:41 AM

Hi,
the repeated division is the standard algorithm for converting bases. In Germany, we call it "reverse Horner's scheme", but there may be different names.
No idea why ManiacDan calls it a "cheat" and claim that it only works for base 10. It works for any two bases.
If you wanted to, say, get the base 5 representation of 1526(7), you'd divide 1526(7) by 5 (in base 7). The remainder is the last digit of the base 5 representation. And the result is again divided by 5 etc.
This is very simple and quick. The "alternative" described by ManiacDan may work for small numbers, but it's completely inappropriate for bigger numbers or actual algorithm. Or would you tell me real quick what's the next biggest power of 42 for 52398257916?
Last edited by Jacques1; September 27th, 2013 at 04:44 AM.
September 27th, 2013, 08:05 AM

Originally Posted by Jacques1
It works for any two bases.
If you wanted to, say, get the base 5 representation of 1526(7), you'd divide 1526(7) by 5 (in base 7).
Thank you. This is good to know. So far, I have only tried it for base 10.