0% found this document useful (0 votes)
33 views39 pages

Unit 2 (Comp Science)

Chapter Two discusses data representation methods in digital technology, explaining how computers store various types of information using binary code (0's and 1's). It introduces units of data representation, including bits, bytes, and words, and outlines different number systems such as decimal, binary, octal, and hexadecimal. The chapter emphasizes the advantages of the binary system for digital computing and provides insights into converting between different number systems.

Uploaded by

geranisco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views39 pages

Unit 2 (Comp Science)

Chapter Two discusses data representation methods in digital technology, explaining how computers store various types of information using binary code (0's and 1's). It introduces units of data representation, including bits, bytes, and words, and outlines different number systems such as decimal, binary, octal, and hexadecimal. The chapter emphasizes the advantages of the binary system for digital computing and provides insights into converting between different number systems.

Uploaded by

geranisco
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

CHAPTER TWO

DATA REPRESENTATION AND


DIGITAL TECHNOLOGY

1
DATA REPRESENTATION METHOD
 Data representation refers to the methods used to represent
information stored in a computer.
 Computers stores many different types of information such as
numbers, text, graphics of several varieties (still image,
video, animation and sound)
 All types of information are stored in a computer in the same
simple format: 0’s and 1’s
 How can 0’s and 1’s represent things as diverse as your
photograph, your favorite song, a recent movie and your
letter?
 It all depends on how we interpret the information
 Computers use numeric codes to represent all the
information they store.
 The codes used by computers are based on the binary number
system instead of the more familiar decimal number system 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.

1. 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 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. 3


2. 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). 4
CONT…

 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
5
3. 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.
 A group of four bits is called a nibble (or nybble).

 Bytes, therefore, consist of two nibbles: a “high-order nibble,”


and a “low-order” nibble.
6
Number System
A number system is a set of symbols used for counting.
 We have already seen that inside a computer system, data is stored in
a format that can not be easily read by human beings.
This is the reason why input and output (I/O) interfaces are
required.
 Different characteristics that define a number system include the :
i) Number of independent digits used in the number system
ii) The place values of the different digits constituting the number and
iii) The maximum numbers that can be written with the given number
of digits.
 Among the three characteristic parameters, the most fundamental
is the number of independent digits or symbols used in the
number system.
 It is known as the radix or base of the number system.
 The decimal number system with which we are all so familiar can
be said to have a radix of 10 as it has 10 independent digits, i.e. 0,
1, 2, 3, 4, 5, 6, 7, 8 and 9.
7
 Similarly, the binary number system with only two
independent digits, 0 and 1, is a radix-2 number
system.
 The octal and hexadecimal number systems have a
radix (or base) of 8 and 16 respectively.
 The place values of different digits:
 For the integer part of the number are given by r0, r1,
r2, r3 and so on, starting with the digit adjacent to the
radix point.
 For the fractional part, these are r−1, r−2, r−3 and so on,
again starting with the digit next to the radix point.
 Here, r is the radix of the number system.
 Also, maximum numbers that can be written with n
digits in a given number system are equal to rn.
8
1. Decimal Number System
 The decimal number system is a radix-10 number
system and therefore has 10 different digits or symbols.
 These are 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.
 All higher numbers after ‘9’ are represented in terms of
these 10 digits only.
 The place values of different digits in a mixed decimal
number:
 Starting from the decimal point, are 100, 101, 102 and so
on (for the integer part) and 10−1, 10−2, 10−3 and so on
(for the fractional part).
 The value or magnitude of a given decimal number can
be expressed as the sum of the various digits multiplied
by their place values or weights.
9
 As an illustration, in the case of the decimal number
3586.265:
 The integer part (i.e. 3586) can be expressed as
3586 = 6×100 +8×101+5×102 +3×103 = 6+80+500+3000 =
3586
 The fractional part(i.e, .256) can be expressed as
265 = 2×10−1+6×10−2 +5×10−3 = 0.2+0.06+0.005 = 0.265.
 The place values are a function of the radix of the
concerned number system and the position of the digits.
 Each digit having a place value depending upon the
position of the digit and the radix of the number system
is equally valid for the other more relevant number
systems.
 Corresponding to the 1’s and 2’s complements in the
binary system, in the decimal number system we have the
9’s and 10’s complements. 10
 The 9’s complement of a given decimal number is
obtained by subtracting each digit from 9.
 For example, the 9’s complement of (2496)10
would be (7503)10.
 The 10’s complement is obtained by adding ‘1’ to
the 9’s complement.
 The 10’s complement of (2496)10 is (7504)10.

11
2. Binary Number System
 The binary number system is a radix-2 number system
with ‘0’ and ‘1’ as the two independent digits.
 All larger binary numbers are represented in terms of
‘0’ and ‘1’.
 The procedure for writing higher order binary numbers
after ‘1’ is similar to the one explained in the case of the
decimal number system.
 For example, the first 16 numbers in the binary number
system would be 0, 1, 10, 11, 100, 101, 110, 111, 1000,
1001, 1010, 1011, 1100, 1101, 1110 and 1111.
 The next number after 1111 is 10000, which is the
lowest binary number with five digits.
 This also proves the point made earlier that a maximum
of only 16 (= 24 numbers could be written with four
digits). 12
 Why do we select the binary number system to deal with?
 It is because data representation in computers is by either the
presence or absence of electronic or magnetic signals in its
circuitry or the media it uses.
 That means an ON or OFF switch, a positive or negative voltage,
north or south magnetization
 We can associate the digits 0 and 1 with this situations, since it
has only two digits.
Digits Status
1 ON
0 OFF
1 North
0 South
1 Positive
0 Negative
 Anyway, the digits of binary number system are called bits. Bit is
a compression of binary digits. 13
 The place values of different digits in a mixed
binary number are 20, 21, 22 and so on (for the
integer part) and 2−1, 2−2, 2−3 and so on (for the
fractional part).
 Example 1.1 Consider an arbitrary number
system with the independent digits as 0, 1 and X.
 What is the radix of this number system? List the
first 10 numbers in this number system.
 Solution
 The radix of the proposed number system is 3.
 The first 10 numbers in this number system would be 0,
1, X, 10, 11, 1X, X0, X1, XX and 100.
14
Advantages of Binary System
1. Logic operations are the backbone of any digital
computer, although solving a problem on computer could
involve an arithmetic operation too.
 The introduction of the mathematics of logic by George
Boole laid the foundation for the modern digital
computer.
 Reduced the mathematics of logic to a binary notation of
‘0’ and ‘1’.
 Mathematics of logic (also known as Boolean algebra)
had been reduced to a binary notation, the binary
number system had a clear edge over other number
systems for use in computer systems.
2. All kinds of data could be conveniently represented in
terms of 0s and 1s.
15
3. Basic electronic devices used for hardware
implementation could be conveniently and efficiently
operated in two distinctly different modes.
4. Circuits required for performing arithmetic operations
such as addition, subtraction, multiplication, division,
etc., become a simple affair when the data involved are
represented in the form of 0s and 1s.
 The 1’s complement of a binary number is obtained by
complementing all its bits, i.e. by replacing 0s with 1s
and 1s with 0s.
 For example, the 1’s complement of (10010110) 2 is
(01101001)2.
 The 2’s complement of a binary number is obtained by
adding ‘1’ to its 1’s complement.
 The 2’s complement of (10010110)2 is (01101010)2. 16
3. Octal Number System
 It is a radix of 8 and therefore has eight distinct digits.
 The independent digits are 0, 1, 2, 3, 4, 5, 6 and 7.
 The next 10 numbers that follow ‘7’, for example, would be
10, 11, 12, 13, 14, 15, 16, 17, 20 and 21.
 The place values for the different digits in the octal number
system are:
 80, 81, 82 and so on (for the integer part) and
 8−1, 8−2, 8−3 and so on (for the fractional part).
 There are also 7’s and 8’s complements in octal number
system:
 The 7’s complement of a given octal number is obtained by
subtracting each octal digit from 7.
 For example, the 7’s complement of (562)8 would be (215)8.
 The 8’s complement is obtained by adding ‘1’ to the 7’s
complement.
 The 8’s complement of (562) would be (216) . 17
Why do we deal with the octal number system?
 Every digit of the octal number system can be
represented in binary number system using
three(maximum) digits of the binary number system(0
and 1).
 This makes the octal number system relatively easier to
read and translate in to binary number system that the
computer uses.
 Continued-------------------from page 44 of the module

18
4. Hexadecimal Number System
 it is a radix-16 number system and its 16 basic digits are
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F.
 The place values or weights of different digits in a mixed
hexadecimal number are:
 160, 161, 162 and so on (for the integer part) and
 16−1, 16−2, 16−3 and so on (for the fractional part).
 The decimal equivalent of A, B, C, D, E and F are 10,
11, 12, 13, 14 and 15 respectively, for obvious reasons.
 The hexadecimal number system provides a condensed
way of representing large binary numbers stored and
processed inside the computer.
 One such example is in representing addresses of
different memory locations.
19
 Let us assume that a machine has 64K of memory.
 Such a memory has 64K (= 216= 65 536) memory
locations and needs 65 536 different addresses.
 These addresses can be designated as 0 to 65 535 in the
decimal number system and 00000000 00000000 to
11111111 11111111 in the binary number system.
 The decimal number system is not used in computers
and the binary notation here appears too cumbersome
and inconvenient to handle.
 But this inconvenient ways to represent data in a
computer can be easily handled in hexadecimal number
system, because:
 65 536 different addresses can be expressed with four
digits from 0000 to FFFF.
 The hexadecimal number representation is convenient to
handle the contents of the memory . 20
 The 15’s and 16’s complements are defined with
respect to the hexadecimal number system.
 The 15’s complement is obtained by subtracting
each hex digit from 15.
 The 16’s complement is obtained by adding ‘1’
to the 15’s complement
 For example:
 The 15’s complement of (3BF)16 would be
(C40)16.
 The 16’s complement of (2AE)16 would be
(D52)16.
21
Converting one Number System to the other
 The decimal equivalent of a given number in another
number system is given by the sum of all the digits
multiplied by their respective place values.
 The integer and fractional parts of the given number
should be treated separately.
1. Binary-to-Decimal Conversion
 The decimal equivalent of the binary number (1001.0101) 2
is determined as follows:
 The integer part = 1001:
 The decimal equivalent = 1 × 20 + 0 × 21 + 0 × 22 + 1 × 23 =
1+0+0+8=9
 The fractional part = .0101
 Therefore, the decimal equivalent = 0 × 2−1 + 1 × 2−2 + 0 ×
2−3 + 1 × 2−4 = 0 + 0.25 + 0+ 0.0625 = 0.3125
 Therefore, the decimal equivalent of (1001.0101)2 = 9.3125
22
2. Octal-to-Decimal Conversion
 The decimal equivalent of the octal number (137.21)8 is
determined as follows:
 The decimal equivalent of the integer part, 137 = 7 × 80 + 3
× 81 + 1 × 82 = 7 + 24 + 64 = 95
 The decimal equivalent, the fractional part = .21 = 2 × 8−1 +
1 × 8−2 = 0.265
 Therefore, the decimal equivalent of (137.21)8= (95.265)10
3. Hexadecimal-to-Decimal Conversion
 The decimal equivalent of the hexadecimal number
(1E0.2A)16 is determined as follows:
 The decimal equivalent integer part = 1E0= 0 × 160 + 14 ×
161 + 1 × 162 = 0 + 224 + 256 = 480 .
 The decimal equivalent of the fractional part = 2A = 2 ×
16−1 + 10 × 16−2 = 0.164
 Therefore, the decimal equivalent of (1E0.2A)16= (480.164)2310
4. Decimal-to-Binary Conversion
 The integer and fractional parts are worked on separately.
 The binary equivalent of the integer part can be found by
successively dividing the integer part of the number by 2 and
recording the remainders until the quotient becomes ‘0’.
 Then the remainders is arranged in the reverse order constitute the
binary equivalent.
 The binary equivalent of the fractional part is found by successively
multiplying the fractional part of the decimal number by 2 and
recording the carry until the result of multiplication is ‘0’.
 Then the carry sequence written in forward order constitutes the
binary equivalent of the fractional part of the decimal number.
 What is the binary equivalent of the decimal number (13.375)10.?
 The binary equivalent of the integer part of (13)10 is (1101)2
 The binary equivalent of the fractional part, .375 is:
0.375 × 2 = 0.75 with a carry of 0
0.75 × 2 = 0.5 with a carry of 1
0.5 × 2 = 0 with a carry of 1
 The binary equivalent of (0.375)10 = (.011)2
 Therefore, the binary equivalent of (13.375) = (1101.011) 24
5. Decimal-to-Octal Conversion
 The process of decimal-to-octal conversion is similar to
that of decimal-to-binary conversion.
 The progressive division in the case of the integer part
and the progressive multiplication while working on the
fractional part here are by ‘8’ which is the radix of the
octal number system.
 Again, the integer and fractional parts of the decimal
number are treated separately.
 The octal equivalent of the decimal number (73.75) 10 is
as follows:
 The octal equivalent of the integer part is (73) 10 = (111)8
 The octal equivalent of the fractional part = 0.75 is
0.75 × 8 = 0 with a carry of 6, so the octal equivalent of
(0.75)10 = (.6)8
 Therefore, the octal equivalent of (73.75) = (111.6) 25
6. Decimal-to-Hexadecimal Conversion
 The process of decimal-to-hexadecimal conversion is
also similar that of decimal-to-binary conversion.
 Since the hexadecimal number system has a base of 16,
the progressive division and multiplication factor in this
case is 16.
 Let us determine the hexadecimal equivalent of (82.25) 10
 The hexadecimal equivalent of (82)10= (52)16
 The hexadecimal equivalent of the fractional part, 0.25
is:
0.25 × 16 = 0 with a carry of 4
 Therefore, the hexadecimal equivalent of (82.25)10=
(52.4)16.

26
7. Octal–Binary and Binary–Octal Conversions
 An octal number can be converted into its binary
equivalent by replacing each octal digit with its three-
bit binary equivalent.
 We take the three-bit equivalent because, the base of the
octal number system is 8 and it is the third power of the
base of the binary number system, i.e. 2.
 A binary number can be converted into an equivalent
octal number by splitting the integer and fractional
parts into groups of three bits, starting from the binary
point on both sides.
 The 0s can be added to complete the outside groups if
needed.
 Let us find the binary equivalent of (374.26) 8 and the
octal equivalent of (1110100.0100111)2 27
 The given octal number = (374.26)8
 The binary equivalent of this octal number is:
(011 111 100.010 110)2 = (011111100.010110)2
 Any 0s on the extreme left of the integer part and
extreme right of the fractional part of the equivalent
binary number should be omitted.
 Therefore, (011111100.010110)2 = (11111100.01011)2
 The octal equivalent of the given binary number =
(1110100.0100111)2
(1110100.0100111)2 = (1 110 100.010 011 1)2= (001 110
100.010 011 100)2= (164.234)8

28
8. Hex–Binary and Binary–Hex Conversions
 A hexadecimal number can be converted into its binary
equivalent by replacing each hex digit with its four-bit
binary equivalent.
 We take the four-bit equivalent because the base of the
hexadecimal number system is 16 and it is the fourth
power of the base of the binary number system, 2.
 A given binary number can be converted into an
equivalent hexadecimal number by splitting the integer
and fractional parts into groups of four bits, starting
from the binary point on both sides.
 The 0s can be added to complete the outside groups if needed.
 Let us find the binary equivalent of (17E.F6)16 and the hex
equivalent of (1011001110.011011101)2.
29
 The binary equivalent of the given hex number =
(17E.F6)16 is :
(17E.F6)= (0001 0111 1110.1111 0110)2
= (000101111110.11110110)2= (101111110.1111011)2
 The 0s on the extreme left of the integer part and on the
extreme right of the fractional part have been omitted.
 The hexadecimal equivalent of the given binary number
= (1011001110.011011101)2 is:
= (10 1100 1110.0110 1110 1)2
 Therefore, hexadecimal equivalent of the = (0010 1100
1110.0110 1110 1000)2 = (2CE.6E8)16

30
9. Hex–Octal and Octal–Hex Conversions
 For hexadecimal–octal conversion, the given hex number
is firstly converted into its binary equivalent which is
further converted into its octal equivalent.
 An alternative approach is firstly to convert the given
hexadecimal number into its decimal equivalent and then
convert the decimal number into an equivalent octal
number.
 The former method is definitely more convenient and
straightforward.
 For octal–hexadecimal conversion:
 The octal number may first be converted into an
equivalent binary number
 And then the binary number transformed into its hex
equivalent. 31
 The other option is firstly to convert the given octal
number into its decimal equivalent and then convert the
decimal number into its hex equivalent.
 The former approach is definitely the preferred one.
 Let us find the octal equivalent of (2F.C4) 16 and the hex
equivalent of (762.013)8
 The binary equivalent of the given hex number
(2F.C4)16 is:
= (0010 1111.1100 0100)2= (00101111.11000100)2=
(101111.110001)2= (101 111.110 001)2 = (57.61)8.
 The hex equivalent of the given octal number
(762.013)8 is:
= (111 110 010.000 001 011)2= (111110010.000001011)2=
32
Binary Arithmetic
 Two types of operation that are performed on binary data include
arithmetic and logic operations.
 Basic arithmetic operations include addition, subtraction,
multiplication and division.
 AND, OR and NOT are the basic logic functions.
1. BINARY ADDITION
 Adding binary numbers is a very simple task, and very similar to the
longhand addition of decimal numbers.
 As with decimal numbers, you start by adding the bits (digits) one
column, or place weight, at a time, from right to left.
 Carry- a digit (or bit) that is carried over to the next most significant
bit during an N-bit addition operation
 The carry bit is a 1 if the result was too large to be expressed in N
bits. 0+0=0
1+0=1
0+1=1
1 + 1 = 10 ==========sum= 0 and carry =1
1 + 1 + 1 = 11 =======sum= 1 and carry=1 33
 When the sum in one column is a two-bit (two-digit)
number, the least significant figure is written as part of
the total sum and the most significant figure is
"carried" to the next left column.
 Consider the following examples:
1001101 1001001 1000111
+ 0010010 +0011001 +0010110
------------ ----------- -----------
1011111 1100010 1011101
 The addition problem on the left did not require any bits
to be carried, since the sum of bits in each column was
either 1 or 0, not 10 or 11.
 In the other two problems, there definitely were bits to be
carried, but the process of addition is still quite simple.
34
 As we'll see later, there are ways that electronic circuits can
be built to perform this very task of addition, by
representing each bit of each binary number as a voltage
signal (either "high," for a 1; or "low" for a 0).
 This is the very foundation of all the arithmetic which
modern digital computers perform.
2. BINARY SUBTRACTION
 Subtraction is generally simpler than addition since only
two numbers are involved and the upper value
representation is greater than the lower value
representation.
 The problem of "borrow" is similar in binary subtraction to
that in decimal.
 We can construct a subtraction table that has two parts - the
three cases of subtracting without borrow, and the one case
of the involvement of a borrow digit, no matter how far to
the left is the next available binary digit 35
 Binary Subtraction (example 1)
1110
-1001
?
110(10) Borrow Stage
- 100 1
010 1
 (14 – 9 = 5)
 Binary Subtraction (example 2)
10000
- 101
?
0111(10) Borrow ripples to LSB
- 10 1
101 1
(16 – 5 = 11)
36
3. BINARY MULTIPLICATION
 It is actually much simpler than decimal multiplication.
 In the case of decimal multiplication, we need to
remember 3 x 9 = 27, 7 x 8 = 56, and so on.
 In binary multiplication, we only need to remember the
following,
0x0=0
0x1=0
1x0=0
1x1=1
 Note that since binary operates in base 2, the
multiplication rules we need to remember are those that
involve 0 and 1 only.
 As an example of binary multiplication we have 101 times
11, 37
101
x11
 First we multiply 101 by 1, which produces 101.
 Then we put a 0 as a placeholder as we would in decimal
multiplication, and multiply 101 by 1, which produces 101.
101
x11
101
1010 <-- the 0 here is the placeholder
 The next step, as with decimal multiplication, is to add.
 The results from our previous step indicate that we must add 101
and 1010, the sum of which is 1111.
101
x11
101
1010
1111 38
4. BINARY DIVISION
 Binary division is almost as easy, and involves our
knowledge of binary multiplication.
 It is the repeated process of subtraction, just as in decimal
division.
 Take for example the division of 1011 into 11.
11 R=10
11 )1011
-11
101
-11
10 <-- remainder, R
 To check our answer, we first multiply our divisor 11 by
our quotient 11.
 Then we add its' product to the remainder 10, and
compare it to our dividend of 1011. 39

You might also like