Unit A, Chapter-03 Data representation
Unit A, Chapter-03 Data representation
UNIT -A
CHAPTER-3
DATA REPRESENTATION
CONTENTS
NUMBER SYSTEM
POSITIONAL and NON-POSITIONAL NUMBER SYSTEM
TYPES OF POSITIONAL NUMBER SYSTEM
Decimal number system.
Binary numbers system.
Octal number system.
Hexadecimal numbers system.
CONVERSION FROM ONE NUMBERS SYSTEM TO ANOTHER NUMBER SYSTEM
a) Conversion from Decimal to Binary, Octal, Hexadecimal.
b) Conversion from Binary, Octal, Hexadecimal to Decimal.
c) Conversion from Binary, Octal, Hexadecimal to Binary, Octal, Hexadecimal
BINARY ARITHM ETIC
1) Binary addition.
2) Binary subtraction.
3) Subtraction using 1’s complement.
4) Subtraction using 2’s complement.
REPRESENTATION OF SIGNED NUMBERS
COM PUTER CODES
BCD, EXCESS-3 BCD, EBCDIC, ASCII code.
INTRODUCTION
Computer manipulates a different types of data such as letters (A-Z), digits (0-9), special
character (+,-,*,/,#…) and so on. Internally these different types of data stored, represen te d an d
manipulated with the use of suitable codes called binary codes.
Before understand the formation of binary codes i t is necessary for us to understand the variou s
number system.
Number: Is a symbol which holds certain values and have predefined meaning.
Ex: 5five
6six
7seven
Ex: Roman numbers system. It provides a partial solution to the problem of representing
large number. I =1, II=2, V=5, X=10, L=50
The number 55 is represented in roman number system as LV. This number syste m c an n ot
be used effectively to perform arithmetic operations.
1. Decimal number system: The base of decimal number system is 10. It has ten symbols from
0-9. The position of each decimal integer and decimal fraction is represented as posi ti ve an d
negative power of 10.
Ex: (538.45)10
2. Binary number system: The base of binary number system is 2. It has two symbols 0’s and
1’s. The position of each binary bit is represented as a positive and negative power of 2.
Ex: (1010.11)
3. Octal number system: The base of octal number system is 8. It has eight symbols from 0-7.
The position of each octal integer and octal fraction is represented as positive and negative
power of 8.
Ex: (426.47)8
4. Hexadecimal number system: The base of hexadecimal number system is 16. It has sixteen
symbols from 0-9 and A-F. The decimal equivalent of A B C D E and F is 10 11 12 13 14 an d
15 respectively. The position of each hexadecimal integer and fraction is represented as
positive and negative power of 16.
Ex: (BAD.45)16 decimal equivalent of B A D is 12 11 14
NOTE:
Base or Radix of number system: Is defined as a total number of symbols or digits
available in the number system.
MSD (Most Significant Digit): Left most digits have highest value.
LSD (Least Significant Digit): Right most digits have least value.
MSB (Most significant Bit): Left most bits have highest value.
LSB (Least significant Bit): Right most bits have a least value.
The following table shows various decimal numbers and their Binary, Octal and
Hexadecimal equivalent.
DECIMAL BINARY OCTAL HEXADECIMAL
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
b) Conversion from Decimal fraction To Binary, Octal and Hexadecimal number system
(0.125)10 = (?)2= (?)8 = (?)16
Rules
Repeatedly multiply the decimal fraction by the base of binary, octal and hexadecimal
number system.
Note down the integer part for each multiplication until the fractional part becomes 0.
The result is obtained by reading it from top to bottom (ie, 1 st integer as MSD and Last
integer as LSD.
Ex:
i. Decimal integer to Binary, Octal and Hexa-decimal.
(32)10 = (?)2 = (?)8= (?)16
Home work:
1) (61)10 = (?)2 = (?)8= (?)16
2) (128)10 = (?)2 = (?)8 = (?)16
3) (205)10 = (?)2 = (?)8 = (?)16
Home work:
1) (0.25)10 = (?)2 = (?)8 = (?)16
2) (0.125)10 = (?)2 = (?)8 = (?)16
3) (29.25)10 = (?)2 = (?)8 = (?)16
Home work
1) (100010.111)2 = (?)10
2) (75.5)8 = (?)10
3) (29.2)16 = (?)10
Short cut method to convert Binary, Octal, Hexadecimal to Binary, Octal, Hexadecimal
Binary arithmetic:
The processes of performing arithmetic operation s on two binary numbers are called binary
arithmetic.
2) (12)10 + (10)10
2) 0010001
2) 1010101
Binary subtraction: The process of finding the difference of two binary numbers is called binary
subtraction.
b) Subtraction of larger number from smaller number using 1’s complement (ie, 10-25= - 15,
will produce –ve result).
Make the length of both binary numbers equal .
Determine the one’s complement of larger number.
Add one’s complement to the smaller number.
Take a one’s complement of result and put a (-) minus sign to obtain the final answer.
Computer codes:
The computers are used to process numerical and alphanumerical type of data such as ,
alphabets A to Z, number 0-9 and special symbols +,-,*, /, % etc…
These different types of the data are internally represent, store and transmitted with the he l p of
suitable code called computer codes.
Ex: The decimal number 537 is represented in 4-bit BCD code as.
The following table shows the 6-bit BCD code for different characters
CHARACTER BCD CODE CHARACTER BCD CODE
ZONE DIGIT ZONE DIGIT
BIT BIT
A 01 0001 S 11 0001
B - 0010 T - 0010
C - 0011 U -
D - 0100 V -
E - W -
F - X -
G - Y -
H 01 1001 Z 11 1000
I 10 0001 1 00 0001
J - 0010 2 - 0010
K - 3 -
L - 4 -
M - 5 -
N - 6 -
O - 7 -
P - 8 -
Q - 9 -
R 10 1001 0 00 1010
This code was developed by IBM. It is an 8 bit code to represent a total of 28 =256 charac te rs
by adding 4 zone bit (cursor movement, spacing etc.). It is used in l arge computer such as
mainframe computer.
The following table shows 8bit EBCDIC code for different characters.
CHARACTER EBCDIC CODE CHARACTER EBCDIC CODE
ZONE BIT DIGIT ZONE BIT DIGIT
A 1100 0001 S 1110 0001
B - 0010 T - 0010
C - 0011 U -
D - 0100 V -
E - W -
F - X -
G - Y -
H 1100 1001 Z 1110 1000
I 1101 0001 1 1111 0001
J - 0010 2 - 0010
K - 3 -
L - 4 -
M - 5 -
N - 6 -
O - 7 -
P - 8 -
Q - 9 -
R 1101 1001 0 1111 1010
A 1000001 65 a 97
B 1000010 66 b 98
C 1000011 67 c 99
D . 68 d 100
E . 69 e 101
F . 70 f 102
G . 71 g 103
H . 72 h 104
I . 73 I 105
J . 74 J 106
K . 75 k 107
L . 76 l 108
M . 77 m 109
N . 78 n 110
O . 79 o 111
P . 80 p 112
Q . 81 q 113
R . 82 r 114
S . 83 s 115
T . 84 t 116
U . 85 u 117
V . 86 v 118
W . 87 w 119
X . 88 x 120
Y . 89 y 121
Z . 90 Z 122
0 0110000 48
1 . 49
2 . 50
3 . 51
4 . 52
5 . 53
6 . 54
7 . 55
8 . 56
9 . 57
Blank 0100000 32
( . 40
+ . 43
$ . 36
* . 42
) . 41
- . 45
/ . 47
, . 44
= . 61
<return> . 13
<linefeed> . 10
NOTE:
***********