next up previous contents
Next: Addition Up: Binary Numbers Previous: Breaking Down a Binary   Contents

Converting from Decimal to Binary

The previous section shows a method to convert from binary to decimal. It is also possible to reverse the process. Given a decimal number, we can use division to convert it to a binary number.

Let us consider the number 53. This is how we come up with the bits:


$\displaystyle 53 \div 2$ $\textstyle =$ $\displaystyle 26 \mathrm{r} 1$ (8.7)
$\displaystyle 26 \div 2$ $\textstyle =$ $\displaystyle 13 \mathrm{r} 0$ (8.8)
$\displaystyle 13 \div 2$ $\textstyle =$ $\displaystyle 6 \mathrm{r} 1$ (8.9)
$\displaystyle 6 \div 2$ $\textstyle =$ $\displaystyle 3 \mathrm{r} 0$ (8.10)
$\displaystyle 3 \div 2$ $\textstyle =$ $\displaystyle 1 \mathrm{r} 1$ (8.11)
$\displaystyle 1 \div 2$ $\textstyle =$ $\displaystyle 0 \mathrm{r} 1$ (8.12)
$\displaystyle 0 \div 2$ $\textstyle =$ $\displaystyle 0 \mathrm{r} 0$ (8.13)
$\displaystyle 0 \div 2$ $\textstyle =$ $\displaystyle 0 \mathrm{r} 0$ (8.14)
$\displaystyle \dots$     (8.15)

If you read the remainders bottom-up, you have a binary number of $00110101_2$. The leading zeros (to the left) are useless. This means the process could have stopped when the quotient becomes one.


next up previous contents
Next: Addition Up: Binary Numbers Previous: Breaking Down a Binary   Contents
Tak Auyeung 2003-12-03