1
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Check your arithmetic. And what's left over after you take 0 16's away from 1? $\endgroup$ – Ethan Bolker Jun 5 '15 at 0:37
  • $\begingroup$ Hi. That's perhaps because 431 has remainder 15 when dividing by 16. $\endgroup$ – Phicar Jun 5 '15 at 0:37
  • $\begingroup$ @EthanBolker 0.0625 $\endgroup$ – lasec0203 Jun 5 '15 at 1:03
  • $\begingroup$ @Phicar 431/16 = 26.9375 I took 9 for the reminder, how do you get 15? $\endgroup$ – lasec0203 Jun 5 '15 at 1:03
  • 1
    $\begingroup$ Not sure if you know the definition of remainder. When you divide a number $x$ by a number $y$ the remainder is the number $0\leq r<y$ such that $x=y*k+r$ where $k = \lfloor \frac{x}{y}\rfloor$. So, $431=16*26+15$ $\endgroup$ – Phicar Jun 5 '15 at 1:08
2
$\begingroup$

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.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ thanks to everyone. my process was completely wrong. I was taking the first number after the decimal as the remainder. for example 431/16 = 26.9375 (I would pick 9 for the remainder..) $\endgroup$ – lasec0203 Jun 5 '15 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.