Intro: How to Convert Numbers to Binary
This instructable will show you how to convert numbers from decimal, or radix 10, to binary, or radix 2. Binary is the numeral system used to express data stored in computers. All data is stored in a computer as a 0 or 1. This instructable will only cover positive integer values.
The table shown above is a shortcut for converting small numbers from decimal to binary.
Definitions & Terms
Radix - number of unique values per digit used to represent numbers; also called base
Decimal - numbers expressed by the values 0-9 for each digit
Binary - numbers expressed by the values 0-1 for each digit
Note: Count numbers by starting from zero, not one.
Step 1: Understanding Radix
The figure above shows the decimal number 318 broken down. Each digit can be expressed by a value from 0-9 multiplied by a base raised to an exponent. For decimal, the base value is 10. The value of the exponent is based on the digit's place. The least significant (rightmost) digit, 8, is multiplied by 10 to the zeroth power. The next digit, 1, is multiplied by 10 to the first power. This pattern continues, with each added digit getting +1 to their exponent. The value 318 is then computed by taking the sum of the products, which are shown above in the fourth row.
This method can also be applied to binary numbers.
Step 2: Converting From Binary to Decimal
The first figure above shows the binary number 1010. Like decimal, you can multiply each digit by a base raised to an exponent, and then sum those products together to get the value in decimal. However, the base for binary is 2 instead of 10. The sum of the four products, shown in the fourth row above, is:
8 + 0 + 2 + 0 = 10
Therefore, the binary number 1010 is equal to the decimal number 10.
The second figure above shows another example with more complexity.
Step 3: Converting From Decimal to Binary
The table above shows the decimal number 122 broken down into binary. The process for converting from decimal to binary is described below.
The left column contains the decimal number that will be divided by two. The middle column contains the integer result of the left column divided by two, minus any remainders. If the number in the left column is odd, there will be a remainder of 1 put in the right column. The number from the middle column is then placed in the first column of the next row. This process is repeated until you get a value of zero in the middle column. The binary number is then the right column written from bottom to top, left to right.