converting decimal to hexadecimal using division method

2.2k Views Asked by At

Okay so I know the basic procedure of converting a decimal number to any base-r is to divide by r and keep up with reminders until you reach zero. The reminders form the new base that is equivalent to the decimal number.

I successfully converted 431 to binary using the procedure stated above. $\left(431\right)_{10}\:\rightarrow \:\left(1101011111\right)_2$

but for dec to hex I'm not getting the correct conversion $\left(431\right)_{10}\:\rightarrow \:\left(69\right)_{16}$

my work

431/16 = 26 with remainder 9

26/16 = 1 with remainder of 6

1/16 = 0 with remainder of 0.0625 with I took as 0

this is how I calculated $\left(69\right)_{16}$ but the correct answer is $\left(1AF\right)_{16}$

note

The question that I'm working from asks to do both conversions and state which is faster. I know going from dec to hex to binary is faster than going from dec directly to binary.

1

There are 1 best solutions below

1
On BEST ANSWER

It looks like there were just some arithmetic errors. We see that

\begin{align} 431 &= 26 \cdot 16 &+ 15 \\ 26 &= 1 \cdot 16 &+ 10 \\ 1 &= 0 \cdot 16 &+ 1 \end{align}

Reading the remainders upward from the bottom, we have $(1\ 10 \ 15)_{16}$, commonly written as $(1AF)_{16}$.

As noted in the comments, your binary expansion has one too many ones; it should be $(110101111)_2$. For fun, you can get from binary to/from hex directly:

\begin{align} (110101111)_2 &= (1\ 1010\ 1111)_2 \\ &= (1 \ A \ F)_{16} \end{align}

so you could potentially use that as a sanity check.