We will study the decimal, binary, hexadecimal, BCD and octal number systems and learn to convert between number systems.

- We are familiar with the decimal number system. There are 10 digits from 0,1,2,3,4,5,6,7,8,9. After the last digit (9) it returns to 0 with a carry of 1. So the decimal count is 0,1,2,3,4,5,6,7,8,9,10,11...19,20,21 ... The radix or base is the number of unique digits, including zero, that a number system uses to represent numbers. For the decimal system, the radix is ten.
- The binary number system has 2 digits 0,1. Similar to the decimal system, after the last digit (1) it returns to 0 with a carry of 1. So the binary count is 0,1,10,11,100,101 .... The radix for the binary number system is 2.
- The hexadecimal number system has 16 digits 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. Like the decimal system, after the last digit (F) it returns to 0 with a carry of 1. So the hexadecimal count is 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,10,11, ... 1D,1E,1F,20,21,22 .... The radix for the hexadecimal number number system is 16.
- Binary Coded Decimal (BCD) is another method to represent decimal numbers. It is useful because many digital devices (like digital clock) process and display numbers in tens. In this system, numbers are represented in a decimal form, however each decimal digit is encoded using a four bit binary number.
- The octal number system has 8 digits 0,1,2,3,4,5,6,7. After the last digit (7) it returns to 0 with a carry of 1. So the octal count is 0,1,2,3,4,5,6,7,10,11, ... 16,17,20,21,22 .... The radix for the octal number number system is 8.
- A common non decimal number system is our time system. Seconds and minutes are sexagesimal (base 60). There are sixty seconds in a minute, and sixty minutes in an hour. The radix for seconds and minutes is 60.

Decimal | Binary | Hexa | BCD | Octal |
---|---|---|---|---|

Enter a decimal number between 0 and 4095 to convert to its binary, hexadecimal and BCD equivalent.

- Divide the decimal number by 2 and record the remainder on the right and the quotient below.
- Repeat the above step until the quotient is 0.
- Starting from the bottom remainder, read the sequence of remainders upwards to the top and you obtain the binary equivalent of the decimal number.

Each column in a binary number table represents a power of 2. Multiple row 1 with row 2 to get row 3. Sum row 3 to obtain the decimal value.

- Divide the decimal number by 16 and record the remainder on the right and the quotient below.
- Repeat the above step until the quotient is 0.
- Starting from the bottom remainder, read the sequence of remainders upwards to the top and you obtain the hexadecimal equivalent of the decimal number.

Each column in a hexadecimal number table represents a power of 16. Multiple row 1 with row 2 to get row 3. Sum row 3 to obtain the decimal value.

To convert from decimal to BCD, write down the four bit binary pattern for each decimal digit.

To convert from BCD to decimal, divide the number into groups of 4 bits and write down the corresponding decimal digit for each 4 bit group.

- Divide the decimal number by 8 and record the remainder on the right and the quotient below.
- Repeat the above step until the quotient is 0.
- Starting from the bottom remainder, read the sequence of remainders upwards to the top and you obtain the hexadecimal equivalent of the decimal number.

Each column in a octal number table represents a power of 8. Multiple row 1 with row 2 to get row 3. Sum row 3 to obtain the decimal value.

The above binary conversion applies only to positive values. When a fixed number of bits is used to hold only positive values, it is said to be unsigned. The range of positive values that can be represented is 0 to 2^{n}-1, where n is the number of bits used.

It is also possible to represent signed (negative as well as positive) numbers in binary. In this case, part of the total range of values is used to represent positive values, and the rest of the range is used to represent negative values.

The most common binary signed numbers representation is called two’s complement. In two’s complement representation, the highest order bit of the number indicates the sign. If the sign bit (MSB) is 0, the number is positive, and if the sign bit is 1, the number is negative. For positive numbers, the remainder bits hold the unsigned binary of the number. For negative numbers, the lower order bits hold the two's complement of the unsigned binary of the number.

Note that the two’s complement representation can only be used when there are a set number of bits. For n bits, the range of values is -2^{n-1} to 2^{n-1}-1. Enter a decimal number between -128 (-2^{7}) and 127 (2^{7}-1) to show its signed 8 bits binary equivalent.

Enter two decimal numbers between -128 and 127 to add their 8 bits signed binary equivalents. Entering a negative number is the same as subtracting. The binary number is represented by its 2's complement form.

In elementary arithmetic using decimal numbers, a carry is a digit that is transferred from one column of digits to another column of more significant digits during addition.

1 | carry | ||

3 | 8 | 38_{10} | |

+ | 0 | 7 | 7_{10} |

= | 4 | 5 | 45_{10} |

Binary addition is done exactly the same way, except that you have only two digits (0 and 1). Thus

- 0+0 = 0, with no carry,
- 0+1 = 1, with no carry,
- 1+1 = 0, and carry 1
- 1+1+1 = 1, and carry 1

If 2 Two's Complement numbers are added, and they both have the same sign (both positive or both negative), then overflow occurs if and only if the result has the opposite sign. Overflow never occurs when adding operands with different signs.

For more information on the implementation of binary arithmetic in logic circuits, see arithmetic combinational circuits.

With advertising revenues falling despite increasing numbers of learners, we need your help to maintain and improve this site, which takes time, money and hard work. Thanks to the generosity of our learners who gave earlier, you are able to use this site at no charge.

If you have benefited from this site and are able, please **give via Paypal**. It will allow us
to continue into the future. It only takes a minute. Thanks!