Ch02 1
Ch02 1
Data Representation in
Computer Systems
Chapter 2 Objectives
2
Chapter 2 Objectives
3
2.1 Introduction
4
2.1 Introduction
5
2.2 Positional Numbering Systems
6
2.2 Positional Numbering Systems
9 10 2 + 4 10 1 + 7 10 0
5 10 3 + 8 10 2 + 3 10 1 + 6 10 0
+ 4 10 -1 + 7 10 -2
7
2.2 Positional Numbering Systems
= 16 + 8 + 0 + 0 + 1 = 25
8
2.3 Decimal to Binary Conversions
9
2.3 Decimal to Binary Conversions
10
2.3 Decimal to Binary Conversions
11
2.3 Decimal to Binary Conversions
12
2.3 Decimal to Binary Conversions
13
2.3 Decimal to Binary Conversions
14
2.3 Decimal to Binary Conversions
16
2.3 Decimal to Binary Conversions
18
2.3 Decimal to Binary Conversions
19
2.3 Decimal to Binary Conversions
22
2.3 Decimal to Binary Conversions
23
2.3 Decimal to Binary Conversions
25
2.3 Decimal to Binary Conversions
26
2.3 Decimal to Binary Conversions
27
2.4 Signed Integer Representation
28
2.4 Signed Integer Representation
29
2.4 Signed Integer Representation
30
2.4 Signed Integer Representation
Let’s see how the addition rules work with signed magnitude numbers . . .
31
2.4 Signed Integer Representation
• Example:
– Using signed magnitude
binary arithmetic, find the
sum of 75 and 46.
• First, convert 75 and 46 to
binary, and arrange as a sum,
but separate the (positive)
sign bits from the magnitude
bits.
32
2.4 Signed Integer Representation
• Example:
– Using signed magnitude
binary arithmetic, find the
sum of 75 and 46.
• Just as in decimal arithmetic,
we find the sum starting with
the rightmost bit and work left.
33
2.4 Signed Integer Representation
• Example:
– Using signed magnitude
binary arithmetic, find the
sum of 75 and 46.
• In the second bit, we have a
carry, so we note it above the
third bit.
34
2.4 Signed Integer Representation
• Example:
– Using signed magnitude
binary arithmetic, find the
sum of 75 and 46.
• The third and fourth bits also
give us carries.
35
2.4 Signed Integer Representation
• Example:
– Using signed magnitude binary
arithmetic, find the sum of 75
and 46.
• Once we have worked our way
through all eight bits, we are
done.
In this example, we were careful to pick two values whose sum would fit into seven bits. If that is not
36
2.4 Signed Integer Representation
• Example:
– Using signed magnitude binary
arithmetic, find the sum of 107
and 46.
• We see that the carry from the
seventh bit overflows and is
discarded, giving us the
erroneous result: 107 + 46 = 25.
37
2.4 Signed Integer Representation
38
2.4 Signed Integer Representation
• The sign of the result gets the sign of the number that is larger.
39
2.4 Signed Integer Representation
40
2.4 Signed Integer Representation
41
2.4 Signed Integer Representation
43
2.4 Signed Integer Representation
44
2.4 Signed Integer Representation
45
2.4 Signed Integer Representation
We note that 19 in one’s complement is: 00010011, so -19 in one’s complement is:
11101100,
46
2.4 Signed Integer Representation
47
2.4 Signed Integer Representation
• Example:
– Using two’s complement binary
arithmetic, find the sum of 107
and 46.
• We see that the nonzero carry
from the seventh bit overflows into
the sign bit, giving us the
erroneous result: 107 + 46 = -103.
Rule for detecting signed two’s complement overflow: When the “carry in” and the “carry out” of the sign bit
48
2.4 Signed Integer Representation
49
2.4 Signed Integer Representation
50
2.4 Signed Integer Representation
51