2
$\begingroup$

In one of my courses there is a problem to convert $142$ base $10$ to base $16$, I know the answer is $8E$ base $16$ just through dividing $142$ by $16$ but the solution is show to use base $2$ like this $2^7+2^3+2^2+2^1=142$ and then in binary $10001110$ base $2 = 8E$ base $16$. So why do this way and isn't it more time consuming or this the proper way to do things?

  • 0
    You are right, your method is more straightforward.2017-01-01
  • 0
    Base 2 is easier because you don'don't have qoutiants, only remainders. 128 < 142 <256. 142-128=14. 8 <14 <16. 4 <6 <8 and 2=2. So 142 = 128 + 8+4+2=10001110 base 2. Converting to binary to hex is very easy because 16=2^4 so (1000)(1110)=8E. Converting to bases where is a power of the other is easy but not if they aren't.2017-01-01

4 Answers 4

3

It's very fast to compute the base $2$ expansion by succesive divisions. Then you only have to group the digits in the binary expansion by groups of $4$ digits, starting from the right, since $16=2^4$.

For instance, the last hexadecimal digit here is, in binary form, $\;2^3+2^2+2$. As we know that $2^3+2^2+2+1=2^4-1 =F$, we deduce at once that $$2^3+2^2+2=(2^{4}-1)-1=F-1=E.$$ The second hexadecimal digit is $\;2^7=2^3\cdot2^4$, which is, in hexadecimal form, $2^3=8$.

  • 1
    It may also be interesting to note that, if OP is in a computer science course (as I suspect), then the hex <-> binary relationship is probably a lot more important than the decimal -> hex conversion process. It's unlikely they would bother teaching hex if not for its relationship with binary. So avoiding binary may be short-circuiting the course material.2017-01-01
  • 0
    Yes, this is for a CS class called discrete structures instead of math2017-01-02
2

It's not necessary by it may be easier, manually, to repeatedly divide by $2,$ without errors, than by $16:$ $$142=71\cdot 2+0$$ $$71=35\cdot 2+1$$ $$35=17\cdot 2+1$$ et cetera.

Reading the "remainders" from bottom to top gives $142$ in binary. Consecutive groups of 4 binary digits , from right to left, are binary representations of numbers from $0$ to $15,$ which are the base-$16$ digits.

Pick a random $6$-digit number in base $10.$ Try converting it to hexadecimal by using divisions by $2,$ and then try divisions by $16.$ I can find $(57)^{1/3}$ to $3$ decimal places in my head but even on paper I'd still prefer divisions by $2$ to divisions by $16$.

0

To convert from base 10 to base 16 you directly (without going via base 2) you need to divide by 16 at each step and look at the remainder. For small numbers like the 142 you are looking at this is easy but if you wanted to convert a larger number like 83264521 then the calculations are much harder. Without a calculator dividing 83264521 by 16 and finding the quotient and remainder is much slower/harder than dividing by 2 four times.

0

There's a trick to base 2.

142 is even so last digit is 0.

142/2= 71 is odd so the second to last digit is 1. So 10.

(71-1)/2=35 is odd so third digit to last digit is 1. So 110.

(35-1)/2 is odd so fourth digit to last is 1. So 1110.

(17-1)/2= 8 is not only even-- it is $2^3$ so first four digits or 1000. So 142 =10001110.

As $16= 2^4$ to convert to base 16 is (1000)(1110)= 8E.

Converting directly is the same in theory:

142 has remainder 14=E so the last digit is E.

(142-14)/16 = 8 so first digit is 8 so 142=8E.

but it is not as obvious to tell that a number has remainder 14 just by looking at is as it is to tell whether it is odd or even.