How can I convert directly between two non-power-of-ten bases?

In summary, converting between base 10 and another base or between two bases where one is a power of the other can be done using logarithms and successive euclidean divisions. However, for bases that are not powers of each other or for converting directly between two bases, the best approach is to first convert to base 10 and then to the desired base. When converting fractional numbers to another base, an algorithm using successive multiplication and subtraction can be used.
  • #1
caters
229
9
I can most of the time successfully convert between base 10 and another base or another base and base 10 or between 2 bases where one of them is a power of the other(like base 2 and base 4 or base 3 and base 9).

With negative bases I sometimes don't get what I want in that negative base and with fractional bases there are 2 expansions for every rational number greater than or equal to 1, They are an infinite sequence of digits to the left and a terminating or repeating decimal to the right. But how will I know if it is a repeating decimal and what repeats in that repeating decimal?

Like what if I wanted to represent 2/3 in base 1/2?

Also I don't know of an easy way to convert between 2 bases that are not powers of each other or base 10 and another base.

Here is how I convert between base 10 and another base:

1) ##log_n(x) = y## Here n is the base I want to convert to and x is the base 10 number I want to convert.

2) ##y =## some irrational number ##y' =## Just the integer and not the whole irrational

3) ##\frac{x}{n^{y'}}##

4) Write down the integer part(which is equal to ##z##) as the digit in the ##n^{y'}## place

5) ##z*n^{y'}##

6)##x-(z*n^{y'})##

7) repeat until you reach the ##n^0## place

8) If needed extend it to decimals in base ##n##.

When I convert between 2 bases that are powers of each other I start from the right and make n groups of ##log_x(y)## digits where ##x## is the current base and ##y## is a power of that base. I then take those groups as if they were individual numbers themselves, add up their values and write down their values from right to left

But how can I convert directly between 1 base and another base when it is neither one of these 2 previous scenarios like for example converting directly from base 2 to base 3?
 
Mathematics news on Phys.org
  • #2
If you want to convert a positive integer from base 10 to base b (b integer greater than 1), you can do it by successive euclidean divisions :

## n = b q_0 + r_0 ##
## q_0 = b q_1 + r_1 ##
...
## q_{k-1} = b q_k + r_k ##
...
until the quotient is 0.
In the end, ##n = \sum_{k=0}^m r_k b^k ##. So, collecting the remainders gives you the conversion from base 10 to b : ##(n)_b = (r_m...r_0)##

If you want to convert from base b to c, the only option I know (and I don't know much), you can go from base b to 10 and from base 10 to c.

Assume that you now you have a positive real number in base 10 with fractional part x, and you want to convert x to base b, so that ## x = \sum_{k=1}^p s_k b^{-k} ##. An algorithm that gives you the ##s_k## is :

## s_1 = \lfloor bx \rfloor, x \leftarrow bx - s_1 ##
...
## s_k = \lfloor b x\rfloor, x \leftarrow bx - s_k ##
until ##x=0##

But I have the feeling you already know that, and probably better than me :confused:
 
  • #3
For the specific case "write 2/3 in base 1/2", start by noting that 2/3 is larger than 1/2. But 2/3- 1/2= 1/6 which is less than 1/2 so the first "digit" right of the "decimal" point is 1: it starts "0.1...". Now note that (1/2)^2= 1/4 is larger than 1/6. The next place is 0: we have "0.10...". (1/2)^3= 1/8 is less than 1/6 and 1/6- 1/8= 2/48= 1/24 is less than 1/2: now we have "0.101...". (1/2)^4= 1/16 is larger than 1/24 so the next place is 0: "0.1010...". Continue like that. Of course, this will be a non-terminating "decimal".

(I put words like "digit" and "decimal" in quotes because those names are, of course, derived from the Greek "deci" for one-tenth and don't really apply to other bases.)
 

What is converting between bases?

Converting between bases is the process of changing a number from one numerical base to another. This is commonly done between decimal (base 10) and binary (base 2) numbers, but can also be done between other bases such as octal (base 8) and hexadecimal (base 16).

Why is converting between bases important?

Converting between bases is important in computer science and digital technology as it allows us to represent and manipulate data in different numerical systems. It also helps in understanding how different bases work and how numbers can be represented in various ways.

What are the steps involved in converting between bases?

The steps involved in converting between bases include: 1) Starting with the given number in one base, 2) dividing the number by the new base and keeping track of the remainders, 3) writing the remainders in reverse order to form the new number in the new base.

What is the most common conversion between bases?

The most common conversion between bases is between decimal and binary numbers. This is because binary is the fundamental language used in computers and most digital devices, and decimal is the standard numerical system used in everyday life.

Are there any shortcuts or tricks for converting between bases?

Yes, there are some shortcuts and tricks that can make converting between bases easier. For example, when converting from binary to decimal, you can use the doubling method to quickly calculate the decimal value. Additionally, memorizing the powers of 2 can also be helpful when converting between binary and other bases.

Similar threads

Replies
7
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
878
Replies
4
Views
920
Replies
4
Views
402
Replies
3
Views
254
Replies
1
Views
2K
  • Programming and Computer Science
Replies
1
Views
949
  • Programming and Computer Science
Replies
17
Views
1K
  • Linear and Abstract Algebra
Replies
33
Views
3K
Replies
5
Views
1K
Back
Top