Introduction to Computer Applications CH-4
2016
Chapter Four
Data Representation computers
4.1 Introduction
Data representation is how the numbers represented to calculate, edit, save and use.
We enter data into a computer or review (see) output data from a computer using the letter of
alphabet, various special symbols, and the numerals in the decimal number system. But since
computer is an electronic device which understands electrical flow (signal) there is no letter,
symbol or number inside the computer. Computer works with binary numbers. As a
semiconductor is conducting or isn’t conducting; a switch is closed or opened.
So data are represented in the form of a code which can have a corresponding electrical signal.
Every computers store numbers, letters, and other special characters in coded form.
4.2 UNITS OF DATA REPRESENTATION
When data is stored, processed or communicated within the computer system, it is packed in
units;
Arranged from the smallest to the largest, the units are called bit, byte and word;
These units are based on the binary number system;
BIT
Bits are the smallest units and can convey only two possible states 0 or 1;
bit stands for binary digits;
A bit is a single element in the computer, on a disk that stands for either “ON” indicating 1
or “OFF” indicating 0;
In the computer “ON” is represented by the existence of current and “OFF” is represented by
the non-existence of current
On a magnetic disk, the same information is stored by changing the polarity or magnetized
particles on the disk’s surface;
BYTE
Bits can be organized into large units to make them represent more and meaningful
information;
This large unit is called a byte and is the basic “unit of data representation” in a computer
system;
The commonly used byte contains 8 bits;
Since each bit has two states and there are 8 bits in a byte, the total amount of data that can
be represented is 28 or 256 possible combinations;
Each byte can represent a character(a character is either a letter, a number or a special
symbol such as +,-,?,*, $, etc
Page 1 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
A byte is then used as a unit of measurement in the computer memory, processing unit,
external storage and during communication;
If the computer memory is 524288 byte, this is expressed in short by saying 512KB, where
KB stands for kilobyte.
1 Kilobyte(1KB) is 210 or 1024 bytes
1 Megabyte(MB) is 220 bytes or 210 kilobytes
1 Gigabyte(GB) is 230 bytes or 220 kilobytes or 210 megabytes
WORD
Word refers the number of bits that a computer process at a time or a transmission media
transmits at a time
Although bytes can store or transmit information, the process can even be faster if more than
one byte is processed at a once;
A combination of bytes, then form a “word”
A word can contain one, two, three or four bytes based on the capacity of the computer;
Word length is usually given in bits
We say that a computer is an 8-bits, a 16 bit, a 32 bit or a 64 bit computer to indicate that the
amount of data it can process at a time;
The large the word length a computer has the more powerful and faster it is.
4.3 Number system
Different Number Systems
Decimal Number System – with the base of 10 and symbol used are 0,1, 2……..9
Binary Number System – with the base of 2 and symbol used are 1 & 0.
Octal Number System – with the base of 8 and symbol used are 0,1,… 7
Hexadecimal Number System – with the base of 16 and symbol used are 0, 1,….9, A, B,
… F representing the decimal values 10, 11... 15.
Conversion via Decimal
2 470
A. Decimal to Binary: 2
2 2353 0
1
2 117
6 0
58
470610 = _________________ 2
2 629 0
2
28 14 0
Answer: 10010011000102
27 73 1
4
More examples: 36 1
2 18 0
▪ 169410 = ?2 29 0
▪ 13510 = ?2 24 1
22 0
20 1 0 1
Page 2 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
B. Decimal to Octal number
Example: 250210 = ________ 8
Answer: 47068 82
3
85 6
More Examples: 81
3 0
▪ 56210 = ?8 80
4 7
▪ 261410 = ?8 9
0
2 4
2
C. Decimal to Hexadecimal
14
Example: 42810 = _______ 16
Answer: 1AC16 121
12
6011
More samples:
6621
257310 = ?16
68 0
456310 =?16
=
=
D. Binary to Decimal: C
Example: A
110012 = _______ 10
Answer: 2510
More Examples:
• 1111012 = ?10
• 101010102 = ?10
E. Octal to Decimal
Example:
5628 = ________ 10
Answer: 37010
More samples:
• 7628 = ?10
• 51278 = ?10
Page 3 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
F. Hexadecimal to Decimal
Example:
2A3B16 = _________ 10
Answer: 1081110
More samples:
• A2BD416 =?10
• CFFE216 = ?10
Other Conversions
a. Binary to Octal
Octal Binary
Example:
0 000
1011102 = _____ 8 1 001
Answer: 568 2 010
3 011
b. Octal to Binary
4 100
Example:
5 101
5628 = _____ 2
6 110
Answer: 101 110 0102
7 111
Page 4 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
c. Binary to Hexadecimal
Example:
Answer:
110100112 = _______ 16
D316
1101
D
Example: 1110001102 = ______ 16
0011
Answer: 1D316
00011
d. Hexadecimal to Binary 31
Example: 2AB16 = _______ 2 10001
216 D
=
10
Answer: 0010101010112
HEXA- Binary 00103 2
DECIMAL
0 0000 A16 =
1
2
0001
0010
10102
3 0011 B16 =
4 0100
5 0101 10112
6 0110
7 0111
8 1000
9 1001
A 1010
B 1011
C 1100
D 1101
E 1110
F 1111
Page 5 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
Fractional Numbers
It isgenerally same way in the decimal number.
0.235 = (2X10-1) + (3X10-2 )+ (5X10-3)
68.53 = (6X101) + (8X100) + (5X10-1) + (3X10-2)
Position 4 3 2 1 0
. -1 -2 -3 -4
Position Value 24 23 22
21 2 0 . 2-1 2-2 2-3 2-4
Quantity
Represented 16 8 4 2
1 . ½ ¼ 1/8 1/16
Example:
Find the decimal equivalent of the binary number 110.1012.
Solution:
110.1012 = 1 x 22 + 1 x
21 + 0 x 20 + 1 x 2-1 + 0 x
2-2 + 1 x 2-3 Another example:
Find the decimal
= 4 + 2 + 0 + 0.5 equivalent of the
hexadecimal
+ 0 + 0.125 number 2B.C4 . 16
= 6 + 0.5 + 0.125 Solution:
2B.C416 ==6.625 2x16110+ Bx160
+ cx16-1 + 4x16-2
Page 6 Prepared by Tseganesh M CS@WCU For Biology students
= 32 + 11
+ 12/16 + 4/256
Introduction to Computer Applications CH-4
2016
Another example:
Find the decimal equivalent of the octal number 127.548.
Solution:
Converting fractional numbers to binary.
0.256 x 2
Example: 0.256 = ______
10 2
= 0.512
Answer: 0.0100000112
0
0.512 x 2
= 1.024
Computer Arithmetic:
1
A. Binary Addition
0.024 x 2
Is performed in the same manner as in decimal arithmetic.
Since 1 is the largest digit in the binary number system, any sum greater than 1 requires a
digit to be carried over. = 0.048
0 +0 0
0
0+1 1
1+0 1
0.048 x 2
1+1 0= plus0.096
a
0
carry of 1
Example:
1.) 101 + 10
0.096 x 2
B D
2 2
= 0.192
i ec 0
Page 7 Prepared by Tseganesh1n im
M
a al
CS@WCU
0.192 x 2
= 0.384
For Biology students
5
0r
+
0
Introduction to Computer Applications CH-4
2016
2.) 100112 + 10012
carry
-1 1
1
B. Binary Subtraction – is applied to subtraction of numbers in
other number systems.
10 1
a. Determine if it is necessary to borrow.
b. If the subtrahend (the lower digit) is larger than the
9
minuend (the upper digit), it is necessary to borrow
01
from the column to the left.
+
c. It is important to note here that the value borrowed
depends upon the base of the number system.
1
d. Simply to subtract lower value from the
upper value. 0–0 0
1–0 1
+ 9 1–1
0–1
0
1 with a borrow
10 12
from the next
Example: column
2
Subtract 011102 from 101012
Answer - 001112
01 8
0202
Additive Method of subtraction – is known as complementary
111010
subtraction.
Complement subtractions:
1
For a number which has n digits in it, a complementary
Example:
10-
is defined as the difference between the numbers and
the based raised to the nthpower minus one.
0111
00
Find the complement of 3710.
Page 8 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
Solution:
Since the number has 2
digits, and the value of base is
10.
(Base)n – 1 = 102 – 1 = 99
Now, 99 – 37 = 62
Hence, the complement of
3710 = 6210
Another example:
Find the complement of 101012.
Solution:
Since the number has 5 digits,
and the value of base is 2.
(Base)n – 1 = 25 – 1 = 3110
Also, 101012 = 2110
Now, 3110 – 2110 = 1010 - 10102
Hence, the complement of
101012 = 010102
Subtraction by the complementary method involves the following steps:
Find the complement of the number you are subtracting (subtrahend)
Add this to the number form which you are taking away (minuend)
If there is a carry 1, add it to obtain the result; if there is no carry, recomplement the sum
and attach a negative sign to obtain the result.
Example:
Subtract 5610 from 9210 using complementary method.
Page 9 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
C. Binary Multiplication – also follows the same general rules as multiplication in decimal
number system.
0X0 0
0X1 0
1X0 0
1X1 1
Example:
Multiply the binary numbers 1010 and 1001
Solution:
Multiplica
1010 Partialnd
X Multiplier
product
1001 Partial
Final product
product
1010 Partial
D. Binary product Division – it is similar to
decimal0000 division. The rules for binary
division are: Partial
2 Perform a series product
1 Start from the left of the dividend
of subtractions, in which the
divisor0000 is subtracted form the dividend.
3 If subtraction is possible, put a 1 in the quotient
1010
and subtract the divisor form the corresponding
digits of dividend.
1011
4 If subtraction is not possible (divisor greater
010
than remainder),
Page 10 Prepared by Tseganesh M CS@WCU
record a 0 in the quotient.
For Biology students
Introduction to Computer Applications CH-4
2016
5 Bring down the next digit to add to the remainder digits. Proceed as before in a manner
similar to long division.
0÷1 0
1÷1 1
Example:
Divide binary 100001 by 110.
010 Quotient
1 10
11
Dividend
1 1 Add
Divisor greater than 100, hence, put 0
in quotient
digit from dividend to group used
100
1 00
011 2 Remainder
Subtract
above
quotient
possible, hence, put 1 in
from subtraction plus digit from
0 0
0110 3 quotient
Divisor greater, hence, put 0 in
011
dividend
Add digit from dividend to group used
10
0
11 4 above
Subtract possible, hence, put 1 in
0
0111remaindequotient
0 5
r
6 Computer Codes
7 There are three
basic computer codes. These are:
BCD Code – Binary Coded Decimal
EBCDIC – Extended Binary-Coded Decimal Interchange Code.
ASCII – American Standard Code for Information Interchange.
1. BCD Code
Page 11 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
BCD equivalent of
decimal digits.
Sample:
4210 =
or
01000010 01000010
4210 = ? In BCD
4 2 in BCD
Page 12 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
2. EBCDIC Code
The BCD code was extended from 6-bit to 8-bit code.
The added 2 bits are used as additional zone bits, expanding the zone to 4 bits.
The resulting code is called EBCDIC.
It is possible to represent 256 (28) different characters, instead of 64 (26).
The control characters are used to control such activities as printer vertical spacing,
movement of cursor on the terminal screen, etc.
All of the 256 bit combinations have not yet been assigned characters.
Character EBCDIC Code Hexadecimal
Equivalent
Zone Digit
A 1100 0001 C1
B 1100 0010 C2
C 1100 0011 C3
D 1100 0100 C4
E 1100 0101 C5
F 1100 0110 C6
G 1100 0111 C7
H 1100 1000 C8
I 11 1001 C9
Ch EBCDIC Code Hexadecimal
Page 13 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
ara Zone Digit Equivalent
cte
r
J 1101 0001 D1
K 1101 0010 D2
L 1101 0011 D3
M 1101 0100 D4
N 1101 0101 D5
O 1101 0110 D6
P 1101 0111 D7
Q 1101 1000 D8
R 1101 1001 D9
Ch EBCDIC Code Hexadecimal
ara Equivalent
cte
r Zone Digit
S 1110 0010 E2
T 1110 0011 E3
U 1110 0100 E4
V 1110 0101 E5
W 1110 0110 E6
X 1110 0111 E7
Page 14 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
Y 1110 1000 E8
Z 1110 1001 E9
Character BCD Code Hexadecimal
Equivalent
Zone Digit
0 1111 0000 F0
1 1111 0001 F1
2 1111 0010 F2
3 1111 0011 F3
4 1111 0100 F4
5 1111 0101 F5
6 1111 0110 F6
7 1111 0111 F7
8 1111 1000 F8
9 1111 1001 F9
Numeric Value EBCDIC Sign Indicator
345 F3F4F5 F for unsigned
+345 F3F4C5 C for positive
-345 F3F4D5 D for negative
Page 15 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
Numeric Value Zone Format Packed Format
345 F3F4F5 345F
+345 F3F4C5 345C
-345 F3F4D5 345D
3456 F3F4F5F6 03456F
Sample:
Using Binary notation, write the EBCDIC coding for the word BIT. How many
bytes are required for this representation?
Solution:
B = 1100 0010 in EBCDIC binary notation
I = 1100 1001 in EBCDIC binary notation 11000010 11001001 11100011
T = 1110 0011 in EBCDIC binary notation B I T
3 bytes will be required for this representation, because each letter requires 1 byte (or 8 bits)
Sample:
Write the EBCDIC zoned-decimal coding for the value +256 (use
hexadecimal). How many bytes will be required for this
representation?
Solution:
+256 = F2F5C6 in EBCDIC
Each hexadecimal digit requires 4 bits, and there are altogether 6 hexadecimal digits.
Therefore, 6 X 4 = 24 bits or 3 bytes (8 bits – 1 byte) will required for this representation.
Page 16 Prepared by Tseganesh M CS@WCU For Biology students
Introduction to Computer Applications CH-4
2016
3. ASCII Code
ASCII is of two types – ASCII-7 and ASCII-8.
ASCII-7 is a 7-bit code, which allows 128 (27) different characters.
The first 3-bits are used as zone bits, and the last 4 bits indicate the digit.
ASCII-8 is an extended version of ASCII-7.
It is an 8-bit code, which allows 256 (28) different characters, rather than 128.
Sample:
1. Write the binary coding for the word BOY in ASCII-7. How many bytes are
required for this representation?
2. Write the binary coding for the word SKY in ASCII-8. How many bytes are
required for this representation?
3. Write the hexadecimal coding for the word GIRL in ASCII-7. How many bytes
are required for this representation?
Solution:
1. B = 1000010 in ASCII-7 binary notation
O = 1001111 in ASCII-7 binary notation
Y = 1011001 in ASCII-7 binary notation
Since each character in ASCII-7 requires one byte for its representation, and
there are 3 characters in the word BOY, 3 bytes will be required for this representation.
Solution:
2. S = 10110011 in ASCII-8 binary notation
K = 10101011 in ASCII-8 binary notation
Y = 10111001 in ASCII-8 binary notation
Page 17 Prepared by Tseganesh M CS@WCU For Biology students
10110011 10101011 10111001
S K Y
Introduction to Computer Applications CH-4
2016
Since each character in ASCII-8 requires one byte for its representation, and there are 3
characters in the word SKY, 3 bytes will be required for this representation.
Solution:
3. G = 47 in ASCII-7 hexadecimal notation
I = 49 in ASCII-7 hexadecimal notation
R = 52 in ASCII-7 hexadecimal notation
L = 4C in ASCII-7 hexadecimal notation
47 49 52 4C
G I R L
Since each character in ASCII-7 requires one byte for its representation,
and there are 4 characters in the word GIRL, 4 bytes will be required for this representation.
Page 18 Prepared by Tseganesh M CS@WCU For Biology students