Unit 1-Number System
Unit 1-Number System
Unit 1-Number System
Unit - 1
Introduction
In Digital Computer, data and instructions are stored in computer memory using binary code (or
machine code) represented by Binary digIT’s 1 and 0 called BIT’s.
The data may contain digits, alphabets or special character, which are converted to bits,
understandable by the computer.
The number system uses well defined symbols called digits.
Number systems are basically classified into two types. They are:
o Non-positional number system
o Positional number system
In olden days people use of this type of number system for simple calculations like additions and
subtractions.
The non-positional number system consists of different symbols that are used to represent
numbers.
Roman number system is an example of the non-positional number system i.e. I=1, V=5, X=10,
L=50.
This number system cannot be used effectively to perform arithmetic operations.
1|Page
To determine the quantity that the number represents, the number is multiplied by an integer
power of x depending on the position it is located and then finds the sum of the weighted digits.
Example: Consider a decimal number 512.45(10) which can be represented in equivalent value
as: 5x102 + 1x101 + 2x100 + 4x10-1 + 5x10-2
Digital computer represents all kinds of data and information in the binary system.
Binary number system consists of two digits 0 (low voltage) and 1 (high voltage).
Its base or radix is 2.
Each digit or bit in binary number system can be 0 or 1.
The positional values are expressed in power of 2.
Example: 1011(2), 111(2), 100001(2)
Consider a binary number 11011.10(2) which can be represented in equivalent value
as: 1x24 + 1x23 + 0x22 + 1x21 + 1x20 + 0x2-1 + 0x2-2
Weights 24 23 22 21 20 2-1 2-2
Digits 1 1 0 1 1 1 0
Values 16 8 4 2 1 0.5 0.25
2|Page
Octal Number System
3|Page
Number System Conversions
Binary:
4|Page
2. Steps to convert decimal fraction number to binary number:
Step 3: Repeat the Step 1 and Step 2 until the decimal number cannot be divided further.
Step 4: The first carry will be the MSB and the last carry is the LSB. The equivalent binary
5|Page
Example 2: To convert the decimal number 152.671875(10) to binary.
6|Page
Example 2: To convert the binary number 11011.101(2) to decimal.
Note: If the number is less than 8 the octal number is same as decimal number.
0.3125 x 8 = 2.5000 2
0.5000 x 8 = 4.0000 4
7|Page
2. Steps to convert octal number to decimal number
8|Page
Step 4: The first remainder will be the LSB and the last remainder is the MSB. The equivalent
hexadecimal number is then written from left to right i.e. from MSB to LSB.
9|Page
Conversion from Binary to Octal
Begin at the rightmost 3 bits. If we are not able to form a group of three, insert 0s to the
Write the octal equivalent of each group. Repeat the steps until all groups have been converted.
1 2 7
Therefore, 1010111(2) = 127 (8)
0 6 7
Therefore, 0.110111 (2) = 0.67 (8)
1 5 5 6
Therefore, 1101.10111(2) = 15.56 (8)
Note: To make group of 3 bits, for whole numbers, it may be necessary to add a 0’s to the left of MSB
and when representing fractions, it may be necessary to add a 0’s to right of LSB.
Step 2: Convert each digit to 3-bit binary number. (Each octal digit is represented by a three-
10 | P a g e
Octal digit 0 1 2 3 4 5 6 7
Binary Equivalent 000 001 010 011 100 101 110 111
Begin at the rightmost 4 bits. If we are not able to form a group of four, insert 0s to the
Write the hexadecimal equivalent of each group. Repeat the steps until all groups have
been converted.
0 D 7
Therefore, 0.110111 (2) = 0.D7 (16)
11 | P a g e
Conversion from Hexadecimal to Binary
Using Binary system, we can easily convert octal numbers to hexadecimal numbers and vice-versa
2 010
7 111
4 100
Therefore, 274 (8) = 010 111 100 (2)
Group the bits into group of 4 bits as 0 1011 1100
0 1011 1100
0 B C
Therefore, 274 (8) = BC (8)
12 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
F 1111
A 1010
D 1101
E 1110
1 7 5 3 3 6
Note
Binary Arithmetic
13 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
Binary Addition
The addition of two binary numbers is performed in same manner as the addition of decimal
number.
The basic rules of binary addition are:
Addend1 Addend2 Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
It 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.
4 101 9 1001
+3 + 011 +5 + 101
7 111 14 1110
26 25 24 23 22 21 20
64 32 16 8 4 2 1
1 0 0 1 0 1 1
75 = 64 + 8 + 2 + 1 = 1001011
18 = 16 + 2 = 10010
Carry 1
Append 1 1001011
Append 2 10010
Sum 1011101
Example 3: Add binary number 1011.011 and 1101.111
Carry 1111 11
Append 1 1011.011
Append 2 1101.111 Exercise:
Sum 1) Add 10101 and 11011
11001.010 2) Add 1011101 and 1100111
14 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
Binary Subtraction
Exercise:
1) Subtract 01110 from 10101
2) Subtract 25 from 35
15 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
An integer containing a sign bit followed by magnitude bits are called sign-magnitude integer.
In this method, first bit (MSB) is considered as a sign bit and the remaining bits stand for
magnitude.
Here positive number starts with 0 and negative number starts with 1.
Example: Consider a decimal number 25(10)
2 25
2 12 1 24 23 22 21 20
16 8 4 2 1
2 6 0 1 1 0 0 1
2 3 0
1 1
So the binary number is 11001(2). If we take the size of the word is 1 byte( 8 bits), then the number 25
will be represented as
0 0 0 1 1 0 0 1
16 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
The 2’s complement of a binary number is obtained by taking 1’s complement of the number and
adding 1 to the Least Significant Bit (LSB) position.
The general procedure to find 2’s complement is given by:
2’s Complement = 1’s Complement + 1
17 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
Note:
Negation: It is the operation of converting a positive number to its negative equivalent or a negative
number to its positive equivalent. Negation is performed by performing 2’s complement system.
Example 1: Consider the number +12. Its binary representation is 01100(2). Find the 2’s
complement of +12.
Clearly, this is a negative number since the sign bit is 1. Actually, 10100 represent -12(10)
which is the negative equivalent of the number 12(10)
Example 2: Consider the number -12. Its binary representation is 10100(2). Find the 2’s
complement of -12.
Clearly, this is a positive number since the sign bit is 0. Actually, 01100 represent 12(10) which
is the negative equivalent of the number -12(10)
Most of the computers perform subtraction using complemented number. This is less expensive
because the same addition circuit is used for subtraction with slight changes in the circuit.
In the binary number system we can perform subtraction operation using two methods of
complements:
o Subtraction using 1’s Complement
o Subtraction using 2’s Complement
18 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
Case 1: Subtracting a smaller number from a larger number (Minuend is greater than Subtrahend)
o Step 1: Find the 1’s complement of the subtrahend.
o Step 2: Add this to the minuend.
o Step 3: Carry is generated, this carry is called as the end around carry
o Step 4: Add the end around carry back to the LSB to get the final difference.
Case 2: Subtracting a larger number from a smaller number (Minuend is less than Subtrahend)
o Step 1: Find the 1’s complement of the subtrahend.
o Step 2: Add this to the minuend.
o Step 3: There will be no carry, Re complement the answer to get the difference
19 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
Case 1: Subtracting a smaller number from a larger number (Minuend is greater than Subtrahend)
o Step 1: Find the 2’s complement of the subtrahend.
o Step 2: Add this to the minuend.
o Step 3: Carry is generated, Discard the carry and the remaining bits give the difference.
Minuend 10 0 0 1
2’s Complement of subtrahend +1 0 1 1 1 STEP 2
End around carry
10 1 0 0 0
Discard the carry STEP 3
Difference is
10 0 0
Case 2: Subtracting a larger number from a smaller number (Minuend is less than Subtrahend)
o Step 1: Find the 2’s complement of the subtrahend.
o Step 2: Add this to the minuend.
o Step 3: There will be no carry, hence take the 2’s complement of the answer and place a
negative sign in front.
20 | P a g e
Chapter 3- Data Representation I PUC, MDRPUC, Hassan
Minuend 01 1 0 1 0
2’s Complement of subtrahend +0 1 0 0 0 1 STEP 2
1 0 1 0 1 1
21 | P a g e