Binary/Decimal Converter

Binary/Decimal Converter

Convert between binary and decimal numbers with ease.

The binary system is a numerical system that functions virtually identically to the decimal number system that people are likely more familiar with. While the decimal number system uses the number 10 as its base, the binary system uses 2. Furthermore, although the decimal system uses the digits 0 through 9, the binary system uses only 0 and 1, and each digit is referred to as a bit. Apart from these differences, operations such as addition, subtraction, multiplication, and division are all computed following the same rules as the decimal system.

Almost all modern technology and computers use the binary system due to its ease of implementation in digital circuitry using logic gates. It is much simpler to design hardware that only needs to detect two states, on and off (or true/false, present/absent, etc.). Using a decimal system would require hardware that can detect 10 states for the digits 0 through 9, and is more complicated.

Below are some typical conversions between binary and decimal values:

DecimalBinary
00
11
210
311
4100
7111
81000
101010
1610000
2010100

While working with binary may initially seem confusing, understanding that each binary place value represents 2n, just as each decimal place represents 10n, should help clarify. Take the number 8 for example. In the decimal number system, 8 is positioned in the first decimal place left of the decimal point, signifying the 100 place. Essentially this means:

8 × 100 = 8 × 1 = 8

Using the number 18 for comparison:

(1 × 101) + (8 × 100) = 10 + 8 = 18

In binary, 8 is represented as 1000. Reading from right to left, the first 0 represents 20, the second 21, the third 22, and the fourth 23; just like the decimal system, except with a base of 2 rather than 10. Since 23 = 8, a 1 is entered in its position yielding 1000. Using 18, or 10010 as an example:

18 = 16 + 2 = 24 + 21

10010 = (1 × 24) + (0 × 23) + (0 × 22) + (1 × 21) + (0 × 20) = 18

The step by step process to convert from the decimal to the binary system is:

  1. Find the largest power of 2 that lies within the given number
  2. Subtract that value from the given number
  3. Find the largest power of 2 within the remainder found in step 2
  4. Repeat until there is no remainder
  5. Enter a 1 for each binary place value that was found, and a 0 for the rest

Using the target of 18 again as an example, below is another way to visualize this:

2n 24 23 22 21 20 Instances within 18 1 0 0 1 0 Target: 18 18 - 16 = 2 → 2 - 2 = 0

Converting from the binary to the decimal system is simpler. Determine all of the place values where 1 occurs, and find the sum of the values.

EX: 10111 = (1 × 24) + (0 × 23) + (1 × 22) + (1 × 21) + (1 × 20) = 23

24 23 22 21 20 1 0 1 1 1 16 0 4 2 1

Hence: 16 + 4 + 2 + 1 = 23.