A question on changing bases of numbers

  • Thread starter Thread starter transgalactic
  • Start date Start date
  • Tags Tags
    Bases Numbers
transgalactic
Messages
1,386
Reaction score
0
i want to transform a number in base 6 into a number in base 3


i was looking for a way to transform straight forward without any middle man
("from 6 to 10 and from 10 to 3" that's not the way i am looking for)
 
Physics news on Phys.org
Are you looking for a calculator (see http://www.1728.com/numbbase.htm) or a formula?

The algorithm for conversion into decimal is:

Let's say you have a number

10121 in base 3

and you want to know what it is in base 10. Well, in base three the place values are

1,3,9,27,81

so we have 1 *81 + 0 * 27 + 1 * 9 + 2* 3 + 1* 1

81 +0+ 9 +6 +1 = 97
http://mathforum.org/library/drmath/view/57074.html

In base 5 this is: 97 = 3x25 + 4x5 + 2x1 = 3425.

If you wanted to convert 101213 to base 5 directly, you'd need to figure out the "place values" in base 5.

{1, 3, 9, 27, 81} = {15, 35, 145, 1025, 3115}

Then: 1 *3115 + 0 * 1025 + 1 * 145 + 2* 35 + 1* 15 = (3115 + 145) + (115 + 15) = 3305 + 125 = 3425
 
Last edited:
i am looking for a formula
 
See edits to my post.
 
i know how to convert to ten base from each number
i want to covert from base 6 to base 3 straight forward
 
transgalactic said:
i want to transform a number in base 6 into a number in base 3


i was looking for a way to transform straight forward without any middle man
("from 6 to 10 and from 10 to 3" that's not the way i am looking for)

Easy! Just learn how to add, subtract, multiply, and divide in base 6. Doing so with "3" is very easy, because it is just half of 6 (kind of like working with "5" in base ten). Then convert the exact same way you otherwise would - only in base six. Ex:

12345 base six should be 1010,20111 base three (check me)
 
doGraeF said:
Easy! Just learn how to add, subtract, multiply, and divide in base 6. Doing so with "3" is very easy, because it is just half of 6 (kind of like working with "5" in base ten). Then convert the exact same way you otherwise would - only in base six. Ex:

12345 base six should be 1010,20111 base three (check me)

I'm sorry! I actually wound up calculating the REVERSE sequence: "54321 base six"!

For reference, please let me show you how I arrived at this number - going straight from base six to base three:

15304 base six
______
3)54321 base six

Remainder: 1

3501 base six
______
3)15304 base six ... (I will cease to make this note, and let any following number be base six unless otherwise noted)

Remainder: 1

1140
_____
3)3501

Remainder: 1

232
_____
3)1140

Remainder: 0

50
____
3)232

Remainder: 2

14
___
3)50

Remainder: 0

3
___
3)14

Remainder: 1

1
__
3)3

Remainder: 0

0
__
3)1

Remainder: 1

Now, put the "remainders" in order, starting with the last and ending with the first:

1010,20111 base three (trinary)

Now, let's try "12345 base six":

2513
______
3)12345 base six (as will be the case UON (unless otherwise noted))
-10
23
-23
04
-3
15
-13
Remainder: 2

543
_____
3)2513
-23
21
-20
13
-13
Remainder: 0

153
____
3)543
-3
24
-23
13
-13
Remainder: 0

35
____
3)153
-13
23
-23
Remainder: 0

11
___
3)35
-33
Remainder: 2

2
___
3)11
-10
Remainder: 1

0
__
3)2
Remainder: 2

Now, again, just arrange the respective remainders in reverse order for the trinary equivalent: 2120002 base three (trinary)

(By the way, I have come to prefer grouping my numerical expressions into groups of five bits, instead of three; as you may have noticed. My reason for this preference would actually be quite a long story).

doGraeF
 
An even better answer!

I found an even more convenient method of changing bases. Let's consider base six: "12345" again.

First, we take the left-most digit: "1". Then, if it were "3" or higher, we would convert it to base three, but "1" is the same in base six as in base three.

Second, multiply it by two: 1*2 = 2

Third, multiple by base three "10": 2*10 = 20 base three


Now, we take the second left-most digit: "2", and leave it alone, because it is the same in base six or base three. Then, add it to our running total: 20+2 = 22.

Multiply 22 by 2: 22 * 2 = 110 + 11 = 121.

And multiply 121 by 10: 121 * 10 = 1210.


Now, we take the middle digit: "3", and convert it to base three: "10". Add it to 1210: 1210 + 10 = 1220.

Multiply by 2: 1220 * 2 = 2000 + 1100 + 110 = 10210.

Multiply by 10: 10210 * 10 = 1,02100.


Take second right-most digit: "4", and convert to base three: "11". Add it to 102100: 1,02100 + 11 = 1,02111.

1,02111 * 2 = 2,11222.

2,11222 * 10 = 21,12220.


Take the right-most digit: "5", and convert to base three: "12". Add it to 21,12220: 21,12220 + 12: 21,20002.

So, in summary: work from left to right, take the the digit, convert to base three, multiply by 2, then multiply by base three "10", then convert the next digit to base three and add it to the running total, multiply the running total by 2, multply the running total by base three "10", and etc. until you have finally added the rightmost digit, converted to base three, to the running total. At that point, the running total will be your base six number converted to base three.

Daniel
 
As if I have not already said enough about this (and do bear with me if this seems a little excessive), let's try our other example: 54321 base six. (All numbers will be in base three unless otherwise noted).

First, let's take the left-most digit: "5", and convert it to base three: "12". Now, let's multiply it by two: 12 * 2 = 20 + 11 = 101. Next, multiply it by 10: 101 * 10 = 1010.

Now, we convert the second left-most digit, "4", to base three: 11. Now, add it to our running total: 1010 + 11 = 1021. Multiply running total by 2: 1021 * 2 = 2000 + 110 + 2 = 2112. Multiply it by 10: 2112 + 10 = 21120.

Take the middle digit, "3", and convert to base three: 10. Add it to running total: 21120 + 10 = 21200. Multiply total by 2: 21200 * 2 = 1,10000 + 2000 + 1100 = 1,20100. Multiply it by 10: 1,20100 * 10 + 12,01000.

Add second right-most digit, "2" to total: 12,01000 + 2 = 12,01002. Multiply by 2: 12,01002 * 2 = 20,00000 + 11,00000 + 2000 + 11 = 101,02011. Multiply by 10: 101,02011 * 10 = 1010,02110.

Add right-most digit, "1", to total: 1010,02110 + 1 = 1010,02111.
 
Last edited:

Similar threads

Back
Top