Number System
Number System
Introduction
In digital computers, data and instructions are stored in the computer’s memory using binary code
(or machine code) represented by Binary dig IT 's 1 and 0 called BITs. The data may contain
digits, alphabets or special character, which are then converted to bits, understandable by the
computer. All arithmetic operations are performed using binary bits. The study of different number
systems is necessaryto understand data representation.
The number system uses well defined symbols called digits. The values of digits depend on the
position in which they appear in the number.
Number systems are basically classified into two types. They are,
1. Non-positional number system.
2. Positional number system.
(2)
which can be represented in equivalent
values:
1x24 + 1x23 + 0x22 + 1x21 + 1x20+1x2-1 + 0x2-2 + 1x2-3
Table 3.2 shows the weightage of the positional values of the binary number:
In the binary number 11010(2) the left most bit 1 is the highest order bit. It is called as the most
significant bit (MSB). Rightmost bit 0 is the lower order bit. It is called least significant bit (LSB).
The table 3.3 shows the weightage of the positional values of the octal number:
The table 3.6 shows the weightage of the positional values of the hexadecimal number:
Example 3.7 Consider the binary number 11011.101(2) which can be represented in decimal value
as:
1x24 +1x23+ 0x22 + 1x21 + 1x20 + 1x2-1 + 0 x 2-2 + 1x2-3
The table 3.2 shows the weightage of the positional values of the binary number.
Example 3.9 Consider an octal number 234.56(8) which can be represented in decimal value as:
2x82 + 3x81 + 4x80 + 5x8-1 + 6x8-2
Table 3.3 below shows the weightage of the positional values of the octal number:
Example 3.11 Consider a hexadecimal number 5AF.D (16) which can be represented in decimal
value as:
5x162 + A x 161 + F x 160 + D x 16-1
Table 3.6 shows the weightage of the positional values of the hexadecimal number:
1 7 5 3 3 6
27 = 128 numbers can be represented using 7 bits, numbers from 0 to +127 and 0 to -128.
All modern computers operate based on 2’s complement representation because of its hardware
being simpler which makes the computer work faster.
Binary arithmetic
It involves addition, subtraction, multiplication and division operations which are fundamental to all
digital computers. Binary addition is the most important operation because it can be used to perform other
arithmetic operations.
Binary addition
The basic rules of binary addition are given in table 3.7:
Addend1 Addend2 Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
The above table adds only two bits and gives sum and carry. If a carry is generated, it should be
carried over to the addition of next two bits. Thus the addition is a 3-bit addition.
gives the rules to add two addend bits and a carry generated from the addition of previous
bits.
Addend1 Addend2 Previous carry Sum Carry
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Carry 1
Addend 1 1001011
Addend 2 10010
Sum 1011101
Binary Subtraction
When we subtract a 1 from a 0, it is necessary to borrow 1 from the next left column i.e. from the
next higher order position.
Simple subtraction
75 = 64 + 8 + 2 +1 = 1001011
25 = 16 + 8 + 1 = 11001
Borrow
Minuend 1001011
Subtrahend 11001
Difference 110010
Case1: Subtracting a smaller number from a larger number (minuend is greater than subtrahend)
Step 1: Find the 1’s complement of the subtrahend.
Step 2: Add this to the minuend.
Step 3: Carry is generated. This carry is called as the end around carry.
Step 4: Add the end around carry back to the LSB to get the final difference.
Example 3.28 Subtract 15 from 23 using 1’s compliment
Minuend 23 10111
Subtrahend -15 - 01111
? ?
Minuend 10111
1’s compliment of Subtrahend +10000
End around carry 100111
Add end carry to LSB + 1
Difference 1000
Case 2: Subtracting a larger number from a smaller number (minuend is less than subtrahend).
Step 1: Find the 1’s complement of the subtrahend.
Step 2: Add this to the minuend.
Step 3: There will be no carry. Re-complement the answer to get the difference.
Step 4: Add the end around carry back to the LSB to get the final difference.
Minuend 011001
1’s compliment of Subtrahend + 001011
100100
There is no carry. Therefore re-complement and insert a negative sign, we get - 011011
Computer codes
Computer codes are used for internal representation of data in computers. As computers use binary
numbers for internal data representation, computer codes use binary coding schemes. In binary coding,
every symbol that appears in the data is represented by a group of bits. Thus computer codes represent
various characters, numbers and control keys that the computer user selects on the keyboard. Some of
the commonly used computer codes are:
Binary coded decimal (BCD)
Extended binary coded decimal interchange code (EBCDIC)
American standard code for information interchange (ASCII)
Excess-3 code
Example 3.33: The decimal number 537 would be represented in the XS-3 code as
5 3 7 Decimal digit
0101 0011 0111 8421 BCD Code
0011 0011 0011 Add 3 (0011)
1000 1010 0110 XS-3 Code
There are 8 bit BCD systems. They are EBCDIC and ASCII.
iii. EBCDIC code - EBCDIC stands for Extended Binary Coded Decimal Interchange Code
This coding was developed by IBM. It is an 8 bit code and so it has 28 = 256 possible code groups
This coding scheme is used with large computers as mainframes.