Question

Given (3AC) in base-14. Convert it into BASE-7.

A simple approach is to convert first 3AC into BASE-10 & then to BASE-7 which results in 2105.

I was just wondering that does there exist any direct way of conversion from BASE-14 to BASe-7?

Was it helpful?

Solution 2

I have found one approach.

There is no need to calculate for base 10 and then base 7. It can be done using this formula! If a no X is represented in base 14 as X = an a(n-1) a(n-2) .... a(0)

then in base 7 we can write it as

X=.....rqp

where
p=(2^0)a(0)%7;
q=((2^1)a(1) + p/7)%7
r=((2^2)a(2) + q/7)%7

..........
nth term=((2^n)a(n) + (n-1)th term/7)%7
(will go further because a no. in base 14 will require more digits in base 7).

The logic is simple, just based on properties of bases, and taking into account the fact that 7 is half of 14. Else it would have been a tedious task.

Eg. here it is given 3AC.
C =12;
so last digit is (2^0 * 12)%7 = 5
A=10
next digit is (2^1 * 10 + 12/7)%7 = (20+1)%7=21%7=0
next is 3;
next digit is (2^2 * 3 + 21/7)%7 = (12+3)%7=15%7=1
next is nothing(0);
next digit is (2^3 * 0 + 15/7)%7 = (0+2)%7=2%7=2

Hence, in base 7 number will be, 2105. This method may seem confusing and difficult, but with a little practice, it may come very handy in solving similar types of problems! Also, even if the number is very long, like 287AC23B362, we don't have to unnecessarily find base 10, which may consume atleast some time, and directly compute base 7!

OTHER TIPS

As others have said, there is no straightforward technique, because 14 is not a power of 7.

However, you don't need to go through base-10. One approach is to write routines that perform base-14 arithmetic (specifically addition and multiplication), and then use them to process each base-7 digit in turn: multiply it by the relevant power-of-7, and then add it to an accumulator.

No, there's not really an easy way to do as you wish because 14 is not a power of 7.

The only tricks that I know of for something like this (ex easily going from hex to binary) require that one base be a power of the other.

http://mathforum.org/library/drmath/view/55783.html gives a reasonable clear answer. In short, it's a bit of a pain from the methods I know.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top