Lesson 03
Lesson 03
Notes
3
DATA REPRESENTATION IN THE
COMPUTER
Computer is not a human being. But how does it understand your instuctions? Did you
think about it any time? Computer understands only 1’s and 0’s. Whatever instruction or
input you are giving to computer it converts each instuction / input as 1’s and 0’s. With
the help of these two digits computer can represent video, picture and numbers also.
In this lesson, you will learn methods of data representation in a computer. You will also
learn different types of number systems in data representation.
OBJECTIVES
After reading this lesson you will be able to:
Data representation refers to the method used to represent information stored in a computer.
Computer stores different types of information like number, text, graphics, video, sound,
charts, images etc.
All types of information stored in a computer are stored internally in the form of 0’s and
1’s. It is very interesting that only with 1 and 0 everything is represented. Computers use
numeric codes to represent all the information.
Binary Numbers
Do you know the origin of the word “Bi”? It is a latin word. Do you know the meaning
of the latin word “Bi”? Bi means two. Binary numbers are 0’s and 1’s. Any positive
integer (whole number) can be easily represented by a sequence of 0's and 1's. Numbers
in this form are said to be in base 2 and these are called binary numbers.
Text
Text can be represented easily by assigning a unique numeric value for each symbol used
in the text. For example, the widely used American Standard Code for Information
Interchange (ASCII explained in section 3.3) defines 128 different symbols (all the
characters found on a standard keyboard, plus a few extra), and assigns each symbol to
a unique numeric code between 0 and 127. In ASCII, “A” is 65, “B” is 66, “a” is 97, “b”
is 98, and so forth. When you save a file as “plain text”, it is stored using ASCII. ASCII
format uses 1 byte per character. 1 byte gives only 256 (128 standard and 128 non-
standard) possible characters The code value for any character can be converted to base
2. Any written message made up of ASCII characters can be converted to a string of 0’s
and 1’s.
Graphics
Graphics that are displayed on a computer screen consist of pixels: the tiny “dots” of color
that collectively “paint” a graphic image on a computer screen. The pixels are organized
into many rows on the screen. In one common configuration, each row is 640 pixels long,
and there are 480 such rows. Another configuration is 800 pixels per row with 600 rows,
which is referred to as a “resolution of 800×600”. Each pixel has two properties: its
location on the screen and its colour.
A graphic image can be represented by a list of pixels. Imagine all the rows of pixels on
the screen laid out end to end in one long row. This gives the pixel list, and a pixel's
location in the list corresponds to its position on the screen. A pixel's color is represented
by a binary code, and consists of certain number of bits. In a monochrome (black and
white) image, only 1 bit is needed per pixel: 0 for black, 1 for white, for example. A 16
color image requires 4 bits per pixel. Modern display hardware allows for 24 bits per
pixel, which provides an array of 16.7 million possible colors for each pixel.
Notes
Digital computers internally use binary (base 2) number system to represent data and
perform arithmetic calculations. The binary number system is very efficient for computers,
but not for humans. Representing even relatively small numbers with binary system
requires working with long strings of ones and zeroes.
When you write decimal (base 10) numbers, you use a positional notation system. Each
digit is multiplied by an appropriate power of 10 depending on its position in the number:
For example:
For whole numbers, the rightmost digit position is the one’s position (100 = 1). The
numeral in that position indicates how many ones are present in the number. The next
Notes position to the left is ten’s, then hundred's, thousand’s, and so on.
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
10 1010
In a positional notation system, the number base is called the radix. Thus, the base ten
system that you normally use has a base of 10. When writing numbers in a base other than
ten, or where the base is not clear from the context, it is normal to specify the base using
a subscript. Thus, in a case where the base is not understood, decimal numbers would be
written like this:
In binary, counting follows similar procedure, except that only two symbols 0 and 1 are
used. Thus, after a digit reaches 1 in binary, an increment resets it to 0 but also causes an
increment of the next digit to the left (i.e., 10).
Since binary is a base-2 system, each digit represents an increasing power of 2, with the
rightmost digit representing 20, the next representing 21, then 22, and so on. To determine
the decimal representation of a binary number simply take the sum of products of binary
digits and the powers of 2 which they represent. For example, the binary 100101 is
converted to decimal form as follows:
1001012 = [ ( 1 ) × 25 ] + [ ( 0 ) × 24 ] + [ ( 0 ) × 23 ] + [ ( 1 )
× 2 2 ] + [ ( 0 ) × 21 ] + [ ( 1 ) × 2 0 ] Notes
1001012 = [ 1 × 32 ] + [ 0 × 16 ] + [ 0 × 8 ] + [ 1 × 4 ] + [ 0 × 2 ] + [ 1 × 1 ]
1001012 = 3710
To determine the decimal representation of a octal number simply take the sum of
products of octal digits and the powers of 8 which they represent.
= 549610
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
= 10646210
All four number systems are equally capable of representing any number.
(19)10 = (23)8
Notes
Decimal to Hexadecimal Conversion
4. With the bits, record them in order from bottom to top as that will be the number in
base 16.
Even though many people used to think of computers as "number crunchers", people
figured out long ago that it is important to handle character data. Character data is not
just alphabetic characters, but also numeric characters, punctuation, spaces, etc. Most
keys on the central part of the keyboard (except shift, caps lock) are characters.
21 15 NAK 45 2D -
22 16 SYN 46 2E .
23 17 ETB 47 2F /
24 18 CAN 48 30 0
49 31 1 79 4F O Notes
50 32 2 80 50 P
51 33 3 81 51 Q
52 34 4 82 52 R
53 35 5 83 53 S
54 36 6
84 54 T
55 37 7
85 55 U
56 38 8
86 56 V
57 39 9
87 57 W
58 3A :
88 58 X
59 3B ;
89 59 Y
60 3C <
61 3D = 90 5A Z
62 3E > 91 5B [
63 3F ? 92 5C \
64 40 @ 93 5D ]
65 41 A 94 5E ^
66 42 B 95 5F _
67 43 C 96 60 `
68 44 D
97 61 a
69 45 E
98 62 b
70 46 F
99 63 c
71 47 G
100 64 d
72 48 H
101 65 e
73 49 I
102 66 f
74 4A J
103 67 g
75 4B K
76 4C L 104 68 h
77 4D M 105 69 i
78 4E N 106 6A j
108 6C l 119 77 v
109 6D m 120 78 w
110 6E n 121 79 x
111 6F o 122 7A y
112 70 123 7B z
113 71 p 124 7C {
114 72 q 125 7D |
115 73 r 126 7E {
116 74 s 127 7F ~
117 75 t
3.3.2 EBCDIC
EBCDIC (Extended Binary Coded Decimal Interchange Code) is a character encoding
set used by IBM mainframes. EBCDIC uses the full 8 bits available to it. So, parity
checking cannot be used on an 8 bit system. Also, EBCDIC has a wider range of control
characters than ASCII.
The character encoding is based on Binary Coded Decimal (BCD). The contiguous
characters in the alphanumeric range are formed up in blocks of up to 10, from 0000
binary to 1001 binary. Non alphanumeric characters are almost all outside the BCD
range. There are four main blocks in the EBCDIC code page: 0000 0000 to 0011 1111
is reserved for control characters; 0100 0000 to 0111 1111 are for punctuation; 1000
0000 to 1011 1111 for lowercase characters and 1100 0000 to 1111 1111 for uppercase
characters and numbers.
TERMINAL EXERCISE
1. Convert the following decimal number into binary number.
a) 333 b) 24 c) 643
2. Convert the following decimal number into octal number.
a) 422 b) 78 c) 36
3. Convert the following decimal number into hexadecimal number.
a) 92 b) 54 c) 39
3.1
1. Binary ( 0 or 1) 2. Two 3. 7
4. 10 5. A
3.2
6. 4 7. 0 to 7
8. ASCII
9. American Standard Code for Information Interchange
10. Extended Binary Coded Decimal Interchange Code.