You are on page 1of 16

Number System

1. Introduction: The number system we generally use in our daily lives is a decimal system. In digital systems numbers are represented by a sequence of the bits 1 and 0. On the other hand human beings uses the denary (decimal) number system which consists if the digits 0 to 9.

A common requirement is to convert familiar denary numbers to binary numbers which computers can understand, and to convert long streams of binary digits to denary numbers which people can understand.

2. Denary (Decimal) Number representation: In the denary (decimal) number system there are ten digits, 0 to 9. Ours is the base 10 or radiz-10 system. Note that there is no symbol for 10 or for the base of any system. We count 1,2,3,4,5,6,7,8,9, and then put a 0 in the first column and a new left column, starting at 1 again. Then we count 1-9 in the first column again. The true significance of each number depends on the position of the digit in the number: Each column in our system stands for a power of 10 starting at 100. Example:

Hence 2431=2x103 +4x102 +3x101 +1x100 And 876 =8x102 +7 x101 +6x100 And 67 =6x101 +7 x100

3. Binary Number Representation Binary system is extensively used in digital electronics. A binary number system has two digits, 0 and 1. These two digits represent the two voltage levels high or low. The base or radix of the binary system is 2. It is a positional system i.e., every position is assigned a specific weight. In the digital system each binary digit is called a bit. A group of 4 bits is called nibble. A group of 8 bits is called byte. In a similar manner to decimal representation, the true significance of each number depends on the position of the digit in the number, for example:

Hence 10101 =1x24 +0x23+1x22 +0x21 +1x20 =2210 And 1110 =1x23 +1x22 +1x21 +0x20 =1410 And 110011011 =1x27 +0x26+0x25 +1x24 +1x23+0x22 +1x21 +1x20=15710

4. Converting from Denary to Binary To convert a decimal number to its binary equivalent, the remainder method can be used. (This method can be used to convert a decimal number into any other base.) The remainder method involves the following four steps: (1) Divide the decimal number by the base (in the case of binary, divide by 2). (2) Indicate the remainder to the right. (3) Continue dividing into each quotient (and indicating the remainder) until the divide operation produces a zero quotient. (4) The base 2 number is the numeric remainder reading from the last division to the first (if you start at the bottom, the answer will read from top to bottom). Example: 1. Converting the number 5 to binary form: 5 2 = 2 remainder 1 2 2 = 1 remainder 0 1 2 = 0 remainder 1 Listing the binary number, starting with the last remainder gives: 5 10 = 1012 2. Converting the number 14 to binary form: 14 2 = 7 remainder 0 7 2 = 3 remainder 1 3 2 = 1 remainder 1 1 2 = 0 remainder 1
3

Listing the binary number, starting with the last remainder gives: 14 10 = 11102 3. Convert the decimal number 9910 to its binary equivalent.

The answer, reading the remainders from top to bottom, is 1100011, so 9910 = 11000112.

Convert the following decimal numbers to their binary equivalents:

(a) 4910

(b) 2110

5. Converting a Binary Number to a Decimal Number To determine the value of a binary number (1001 2, for example), we can expand the number using the positional weights as follows:

Here's another example to determine the value of the binary number 11010102:

Convert the following binary numbers to their decimal equivalents: (a) 11001102 (b) 111110012

6. Octal Number System The same principles of positional number systems we applied to the decimal and binary number systems can be applied to the octal number system. However, the base of the octal number system is eight, so each position of the octal number represents a successive power of eight. From right to left, the successive positions of the octal number are weighted 1, 8, 64, 512, etc. A list of the first several powers of 8 follows: 8 =1
0

8 =8

8 = 64

8 = 512

8 = 4096

8 = 32768

7. Converting an Octal Number to a Decimal Number To determine the value of an octal number (3678, for example), we can expand the number using the positional weights as follows:

Here's another example to determine the value of the octal number 1601 8:

Convert the following octal numbers to their decimal equivalents: (a) 5368 (b) 11638

8. Converting a Decimal Number to an Octal Number To convert a decimal number to its octal equivalent, the remainder method (the same method used in converting a decimal number to its binary equivalent) can be used. To review, the remainder method involves the following four steps: (1) Divide the decimal number by the base (in the case of octal, divide by 8). (2) Indicate the remainder to the right. (3) Continue dividing into each quotient (and indicating the remainder) until the divide operation produces a zero quotient. (4) The base 8 number is the numeric remainder reading from the last division to the first (if you start at the bottom, the answer will read from top to bottom).

Example 1: Convert the decimal number 46510 to its octal equivalent:

The answer, reading the remainders from top to bottom, is 721, so 46510 = 7218. Example 2: Convert the decimal number 254810 to its octal equivalent:

The answer, reading the remainders from top to bottom, is 4764, so 254810 = 47648. Convert the following decimal numbers to their octal equivalents: (a) 300210 (b) 651210

9. The Hexadecimal Number System The hexadecimal (base 16) number system is a positional number system as are the decimal number system and the binary number system. Recall that in any positional number system, regardless of the base, the highest numerical symbol always has a value of one less than the base. Furthermore, one and only one symbol must ever be used to represent a value in any position of the number. For number systems with a base of 10 or less, a combination of Arabic numerals can be used to represent any value in that number system. The decimal number system uses the Arabic numerals 0 through 9; the binary number system uses the Arabic numerals 0 and 1; the octal number system uses the Arabic numerals 0 through 7; and any other number system with a base less than 10 would use the Arabic numerals from 0 to one less than the base of that number system. However, if the base of the number system is greater than 10, more than 10 symbols are needed to represent all of the possible positional values in that number system. The hexadecimal number system uses not only the Arabic numerals 0 through 9, but also uses the letters A, B, C, D, E, and F to represent the equivalent of 1010 through 1510, respectively. The same principles of positional number systems we applied to the decimal, binary, and octal number systems can be applied to the hexadecimal number system. However, the base of the hexadecimal number system is 16, so each position of the hexadecimal number represents a successive power of 16. From right to left, the successive positions of the hexadecimal number are weighted 1, 16, 256, 4096, 65536, etc.:
0 1 2 3 4

16 = 1

16 = 16

16 = 256

16 = 4096

16 = 65536

10. Converting a Hexadecimal Number to a Decimal Number We can use the same method that we used to convert binary numbers and octal numbers to decimal numbers to convert a hexadecimal number to a decimal number, keeping in mind that we are now dealing with base 16. From right to left, we multiply each digit of the hexadecimal number by the value of 16 raised to successive powers, starting with the zero power, then sum the results of the multiplications. Remember that if one of the digits of the hexadecimal number happens to be a letter A through F, then the corresponding value of 10 through 15 must be used in the multiplication.

Example 1: Convert the hexadecimal number 20B316 to its decimal equivalent.

Example 2: Convert the hexadecimal number 12AE516 to its decimal equivalent.

Convert the following hexadecimal numbers to their decimal equivalents: (a) 2 4 3 F16 (b) B E E F16

11. Converting a Decimal Number to a Hexadecimal Number To convert a decimal number to its hexadecimal equivalent, the remainder method (the same method used in converting a decimal number to its binary equivalent) can be used. To review, the remainder method involves the following four steps: (1) Divide the decimal number by the base (in the case of hexadecimal, divide by 16). (2) Indicate the remainder to the right. If the remainder is between 10 and 15, indicate the corresponding hex digit A through F. (3) Continue dividing into each quotient (and indicating the remainder) until the divide operation produces a zero quotient. (4) The base 16 number is the numeric remainder reading from the last division to the first (if you start at the bottom, the answer will read from top to bottom).
9

Example 1: Convert 926310 to its hexadecimal equivalent:

The answer, reading the remainders from top to bottom, is 242F, so 926310 = 242F16. Example 2: Convert 425910 to its hexadecimal equivalent:

The answer, reading the remainders from top to bottom, is 10A3, so 425910 = 10A316.

10

Convert the following decimal numbers to their hexadecimal equivalents: (a) 6949810 (b) 11426710 12. Converting Binary-to-Hexadecimal or Hexadecimal-to-Binary Converting a binary number to its hexadecimal equivalent or vice-versa is a simple matter. Four binary digits are equivalent to one hexadecimal digit. To convert from binary to hexadecimal, divide the binary number into groups of 4 digits starting on the right of the binary number. If the leftmost group has less than 4 bits, put in the necessary number of leading zeroes on the left. For each group of four bits, write the corresponding single hex digit.

To convert from hexadecimal to binary, write the corresponding group of four binary digits for each hex digit.

11

13. Converting Binary-to-Octal or Octal-to-Binary Converting a binary number to its octal equivalent or vice-versa is a simple matter. Three binary digits are equivalent to one octal digit. To convert from binary to octal, divide the binary number into groups of 3 digits starting on the right of the binary number. If the leftmost group has less than 3 bits, put in the necessary number of leading zeroes on the left. For each group of three bits, write the corresponding single octal digit.

To convert from octal to binary, write the corresponding group of three binary digits for each octal digit.

12

Addition: 1. Binary Addition Adding two binary numbers together is easy, keeping in mind the following four addition rules: (1) 0 + 0 = 0 (2) 0 + 1 = 1 (3) 1 + 0 = 1 (4) 1 + 1 = 10 Note in the last example that it was necessary to "carry the 1". After the first two binary counting numbers, 0 and 1, all of the binary digits are used up. In the decimal system, we used up all the digits after the tenth counting number, 9. The same method is used in both systems to come up with the next number: place a zero in the "ones" position and start over again with one in the next position on the left. In the decimal system, this gives ten, or 10. In binary, it gives 102, which is read "one-zero, base two." Consider the following binary addition problems and note where it is necessary to carry the 1:

Perform the following binary additions:

13

2. Subtraction Using Complements Subtraction in any number system can be accomplished through the use of complements. A complement is a number that is used to represent the negative of a given number. When two numbers are to be subtracted, the subtrahend* can either be subtracted directly from the minuend (as we are used to doing in decimal subtraction) or, the complement of the subtrahend can be added to the minuend to obtain the difference. When the latter method is used, the addition will produce a high-order (leftmost) one in the result (a "carry"), which must be dropped. This is how the computer performs subtraction: it is very efficient for the computer to use the same "add" circuitry to do both addition and subtraction; thus, when the computer "subtracts", it is really adding the complement of the subtrahend to the minuend. To understand complements, consider a mechanical register, such as a car mileage indicator, being rotated backwards. A five-digit register approaching and passing through zero would read as follows: 00005 00004 00003 00002 00001 00000 99999 99998 99997 etc. It should be clear that the number 99998 corresponds to -2. Furthermore, if we add 00005 + 99998 1 00003 and ignore the carry to the left, we have effectively formed the operation of subtraction: 5 - 2 = 3. The number 99998 is called the ten's complement of 2. The ten's complement of any decimal number may be formed by subtracting each digit of the number from 9, then adding 1 to the least significant digit of the number formed. In the example above, subtraction with the use of complements was accomplished as follows: (1) We were dealing with a five-digit subtrahend that had a value of 00002. First, each digit of the subtrahend was subtracted from 9 (this preliminary value is called the nine's complement of the subtrahend):

(2) Next, 1 was added to the nine's complement of the subtrahend (99997) giving the ten's complement of subtrahend (99998):

14

(3) The ten's complement of the subtrahend was added to the minuend giving 100003. The leading (carried) 1 was dropped, effectively performing the subtraction of 00005 - 00002 = 00003.

The answer can be checked by making sure that 2 + 3 = 5. Another example: Still sticking with the familiar decimal system, subtract 4589 - 322, using complements ("eyeballing" it tells us we should get 4267 as the difference). (1) First, we'll compute the four digit nine's complement of the subtrahend 0322 (we must add the leading zero in front of the subtrahend to make it the same size as the minuend):

(2) Add 1 to the nine's complement of the subtrahend (9677) giving the ten's complement of subtrahend (9678):

(3) Add the ten's complement of the subtrahend to the minuend giving 14267. Drop the leading 1, effectively performing the subtraction of 4589 - 0322 = 4267.

The answer can be checked by making sure that 322 + 4267 = 4589. Solve the following subtraction problems using the complement method: (a) 5086 - 2993 =

15

(b) 8391 - 255 = 3. Binary Subtraction We will use the complement method to perform subtraction in binary and in the sections on octal and hexadecimal that follow. As mentioned in the previous section, the use of complemented binary numbers makes it possible for the computer to add or subtract numbers using only circuitry for addition - the computer performs the subtraction of A - B by adding A + (two's complement of B) and then dropping the carried 1. The steps for subtracting two binary numbers are as follows: (1) Compute the one's complement of the subtrahend by subtracting each digit of the subtrahend by 1. A shortcut for doing this is to simply reverse each digit of the subtrahend - the 1's become 0's and the 0's become 1's. (2) Add 1 to the one's complement of the subtrahend to get the two's complement of the subtrahend. (3) Add the two's complement of the subtrahend to the minuend and drop the high-order 1. This is your difference. Example 1: Compute 110101012 - 10010112 (1) Compute the one's complement of 10010112 by subtracting each digit from 1 (note that a leading zero was added to the 7-digit subtrahend to make it the same size as the 8-digit minuend):

16