[go: up one dir, main page]

0% found this document useful (0 votes)
21 views54 pages

Ch-04 Operation On Data (Compatibility Mode)

The document discusses data types stored in computers and their representation, including integers, real numbers, text, audio, images, and video. It outlines logic operations (NOT, AND, OR, XOR) and their applications at both bit and pattern levels, as well as shift operations (logical and arithmetic) for manipulating bit patterns. The document includes examples and objectives for students to understand and perform these operations effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views54 pages

Ch-04 Operation On Data (Compatibility Mode)

The document discusses data types stored in computers and their representation, including integers, real numbers, text, audio, images, and video. It outlines logic operations (NOT, AND, OR, XOR) and their applications at both bit and pattern levels, as well as shift operations (logical and arithmetic) for manipulating bit patterns. The document includes examples and objectives for students to understand and perform these operations effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

SWISS GERMAN UNIVERSITY

4
Operations
On Data
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 1


19-Apr-16 Foundations of Computer Science Cengage Learning
SWISS GERMAN UNIVERSITY

Previous Lecture…..
• There are 5 data types stored in a computer (number, text, audio, image
and video), all these data types are transformed into bit pattern
• Data (integer numbers) can be transformed into unsigned number, sign &
magnitude, and 2’s complement number representation
• Real numbers can be transformed using floating point representation (Sign,
Exponent, Mantissa)
• The most common code used to store text data is using ASCII code ( 1
character = 7-bit representation)
• Audio data is an analog data and must be converted into digital data
(sampling, quantization, encode) then it can be stored in computer.
• An image data is stored into computer using 2 different technique, raster
graphics and vector graphics.
• A video data is a representation of series of images displayed as a function
of time.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 2


19-Apr-16
SWISS GERMAN UNIVERSITY

Objectives
After studying this chapter, the student should be able to:
 List the three categories of operations performed on data.
 Perform unary and binary logic operations on bit patterns.
 Distinguish between logic shift operations and arithmetic shift operations.
 Perform addition and subtraction on integers when they are stored in
two’s complement format.
❑ Perform addition and subtraction on integers when stored in sign-and-
magnitude format.
❑ Perform addition and subtraction operations on reals stored in floating-
point format.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 3


19-Apr-16
SWISS GERMAN UNIVERSITY
4-1 LOGIC OPERATIONS

In Chapter 3 we discussed the fact that data inside a


computer is stored as patterns of bits
bits.. Logic operations
refer to those operations that apply the same basic
operation on individual bits of a pattern, or on two
corresponding bits in two patterns
patterns.. This means that we
can define logic operations at the bit level and at the
pattern level
level.. A logic operation at the pattern level is n
logic operations, of the same type, at the bit level where
n is the number of bits in the pattern
pattern..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 4


19-Apr-16
SWISS GERMAN UNIVERSITY

Logic operations at bit level


A bit can take one of the two values: 0 or 1. If we interpret 0 as the
value false and 1 as the value true, we can apply the operations
defined in Boolean algebra to manipulate bits. Boolean algebra,
named in honor of George Boole, belongs to a special field of
mathematics called logic. Boolean algebra and its application to
building logic circuits in computers are briefly discussed in Appendix
E. In this section, we show briefly four bit-level operations that are
used to manipulate bits: NOT, AND, OR, and XOR.
i
Boolean algebra and logic circuits are discussed in Appendix
E.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 5


19-Apr-16
SWISS GERMAN UNIVERSITY

Logic operations at the bit level


QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 6


19-Apr-16
SWISS GERMAN UNIVERSITY

NOT
The NOT operator is a unary operator: it takes only one
input. The output bit is the complement of the input.
AND
The AND operator is a binary operator: it takes two inputs.
The output bit is 1 if both inputs are 1s and the output is 0
in the other three cases.

i
For x = 0 or 1 x AND 0 → 0 0 AND x → 0
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 7


19-Apr-16
SWISS GERMAN UNIVERSITY

OR
The OR operator is a binary operator: it takes two inputs. The output
bit is 0 if both inputs are 0s and the output is 1 in other three cases.

i
For x = 0 or 1 x OR 1 → 1 1 OR x → 1

XOR
The XOR operator is a binary operator like the OR operator, with only
one difference: the output is 0 if both inputs are 1s.
i
For x = 0 or 1
1 XOR x → NOT x x XOR 1 → NOT x
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 8


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.1
In English we use the conjunction “or” sometimes to mean an
inclusive--or, and sometimes to means an exclusive
inclusive exclusive--or
or..

a. The sentence “I would like to have a car or a house” uses “or”


in the inclusive sense
sense—
—I would like to have a car, a house or
both..
both

b. The sentence “Today is either Monday or Tuesday” uses “or”


in the exclusive sense
sense——today is either Monday or Tuesday,
but it cannot be both
both..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 9


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.2

The XOR operator is not actually a new operator


operator.. We can always
simulate it using the other three operators
operators.. The following two
expressions are equivalent

x XOR y ↔ [x AND (NOT y)] OR [(NOT x) AND y]

The equivalence can be proved if we make the truth table for


both..
both

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 10


19-Apr-16
SWISS GERMAN UNIVERSITY

Logic operations at pattern level


The same four operators (NOT, AND, OR, and XOR) can be applied
to an n-bit pattern. The effect is the same as applying each operator to
each individual bit for NOT and to each corresponding pair of bits for
the other three operators. Figure 4.2 shows these four operators with
input and output patterns.

Logic operators applied to bit patterns

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 11


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.3

Use the NOT operator on the bit pattern 10011000


10011000..

Solution
The solution is shown below
below.. Note that the NOT operator
changes every 0 to 1 and every 1 to 0.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 12


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.4
Use the AND operator on the bit patterns 10011000 and
00101010..
00101010
Solution
The solution is shown below
below.. Note that only one bit in the output
is 1, where both corresponding inputs are 1s.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 13


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.5

Use the OR operator on the bit patterns 10011001 and 00101110


00101110..

Solution
The solution is shown below
below.. Note that only one bit in the output
is 0, where both corresponding inputs are 0s.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 14


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.6
Use the XOR operator on the bit patterns 10011001 and
00101110..
00101110
Solution
The solution is shown below
below.. Compare the output in this example
with the one in Example 4.5. The only difference is that when the
two inputs are 1s, the result is 0 (the effect of exclusion)
exclusion)..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 15


19-Apr-16
SWISS GERMAN UNIVERSITY

Applications

The four logic operations can be used to modify a bit pattern.


 Complementing (NOT)

 Unsetting (AND)

 Setting (OR)

 Flipping (XOR)

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 16


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.7
Use a mask to unset (clear) the five leftmost bits of a pattern
pattern.. Test
the mask with the pattern 10100110
10100110..

Solution
The mask is 00000111
00000111.. The result of applying the mask is
is::

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 17


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.8
Use a mask to set the five leftmost bits of a pattern
pattern.. Test the mask
with the pattern 10100110
10100110..

Solution
The mask is 11111000
11111000.. The result of applying the mask is
is::

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 18


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.9
Use a mask to flip the five leftmost bits of a pattern
pattern.. Test the
mask with the pattern 10100110
10100110..

Solution
The mask is 11111000
11111000.. The result of applying the mask is
is::

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 19


19-Apr-16
SWISS GERMAN UNIVERSITY
4-2 SHIFT OPERATIONS

Shift operations move the bits in a pattern, changing


the positions of the bits
bits.. They can move bits to the left
or to the right
right.. We can divide shift operations into two
categories:: logical shift operations and arithmetic
categories
shift operations
operations..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 20


19-Apr-16
SWISS GERMAN UNIVERSITY

Logical shift operations


A logical shift operation is applied to a pattern that does not
represent a signed number. The reason is that these shift operations
may change the sign of the number that is defined by the leftmost bit
in the pattern. We distinguish two types of logical shift operations, as
described below:

 Logical shift

 Logical circular shift (Rotate)

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 21


19-Apr-16
SWISS GERMAN UNIVERSITY

Logical shift operations

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 22


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.10

Use a logical left shift operation on the bit pattern 10011000


10011000..

Solution
The solution is shown below
below.. The leftmost bit is lost and a 0 is
inserted as the rightmost bit
bit..

Discarded

Added

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 23


19-Apr-16
SWISS GERMAN UNIVERSITY

Circular shift operations

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 24


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.11

Use a circular left shift operation on the bit pattern 10011000


10011000..

Solution
The solution is shown below
below.. The leftmost bit is circulated and
becomes the rightmost bit
bit..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 25


19-Apr-16
SWISS GERMAN UNIVERSITY

Arithmetic shift operations


Arithmetic shift operations assume that the bit pattern is a signed
integer in two’s complement format. Arithmetic right shift is used to
divide an integer by two, while arithmetic left shift is used to
multiply an integer by two.

Arithmetic shift operations

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 26


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.12
Use an arithmetic right shift operation on the bit pattern
10011001.. The pattern is an integer in two’s complement format
10011001 format..

Solution
The solution is shown below
below.. The leftmost bit is retained and also
copied to its right neighbor bit
bit..

The original number was −103 and the new number is −52
52,, which
is the result of dividing −103 by 2 truncated to the smaller
integer..
integer
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 27


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.13
Use an arithmetic left shift operation on the bit pattern 11011001
11011001..
The pattern is an integer in two’s complement format
format..

Solution
The solution is shown below
below.. The leftmost bit is lost and a 0 is
inserted as the rightmost bit
bit..

The original number was −39 and the new number is −7878.. The
original number is multiplied by two
two.. The operation is valid
because no underflow occurred
occurred.. QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 28


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.14
Use an arithmetic left shift operation on the bit pattern 01111111
01111111..
The pattern is an integer in two’s complement format
format..
Solution
The solution is shown below
below.. The leftmost bit is lost and a 0 is
inserted as the rightmost bit
bit..

The original number was 127 and the new number is −2. Here the
result is not valid because an overflow has occurred
occurred.. The expected
answer 127 × 2 = 254 cannot be represented by an 8-bit pattern
pattern..
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 29


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.15
Combining logic operations and logical shift operations give us some tools
for manipulating bit patterns
patterns.. Assume that we have a pattern and we need
to use the third bit (from the right) of this pattern in a decision
decision--making
process.. We want to know if this particular bit is 0 or 1. The following
process
shows how we can find outout..

We can then test the result


result:: if it is an unsigned integer 1, the target bit was
1, whereas if the result is an unsigned integer 0, the target bit was 0.
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 30


19-Apr-16
SWISS GERMAN UNIVERSITY
4-3 ARITHMETIC OPERATIONS

Arithmetic operations involve adding, subtracting,


multiplying and dividing
dividing.. We can apply these operations
to integers and floating
floating--point numbers
numbers..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 31


19-Apr-16
SWISS GERMAN UNIVERSITY

Arithmetic operations on integers


All arithmetic operations such as addition, subtraction,
multiplication and division can be applied to integers. Although
multiplication (division) of integers can be implemented using
repeated addition (subtraction), the procedure is not efficient. There
are more efficient procedures for multiplication and division, such as
Booth procedures, but these are beyond the scope of this book. For
this reason, we only discuss addition and subtraction of integers
here.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 32


19-Apr-16
SWISS GERMAN UNIVERSITY

Two’s complement integers


When the subtraction operation is encountered, the computer
simply changes it to an addition operation, but makes two’s
complement of the second number. In other words:

A − B ↔ A + (B + 1)
Where B is the one’s complement of B and
(B + 1) means the two’s complement of B

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 33


19-Apr-16
SWISS GERMAN UNIVERSITY

We should remember that we add integers column by


column. The following table shows the sum and carry (C).

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 34


19-Apr-16
SWISS GERMAN UNIVERSITY

Addition and subtraction of integers in two’s complement format

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 35


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.16

Two integers A and B are stored in two’s complement format


format..
Show how B is added to A.

A = (00010001
00010001))2 B = (00010110
00010110))2
Solution
The operation is adding
adding.. A is added to B and the result is stored in
R. (+
(+17
17)) + (+
(+22
22)) = (+
(+39
39)).

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 36


19-Apr-16
Example 4.17 SWISS GERMAN UNIVERSITY
Two integers A and B are stored in two’s complement format
format..
Show how B is added to A.

A = (00011000
00011000))2 B = (11101111
11101111))2

Solution
The operation is adding
adding.. A is added to B and the result is stored in
R. (+24)) + (-17
(+24 17)) = (+
(+77).

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 37


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.18
Two integers A and B are stored in two’s complement format
format..
Show how B is subtracted from A.
A = (00011000
00011000))2 B = (11101111
11101111))2
Solution
The operation is subtracting
subtracting.. A is added to (B + 1) and the result
is stored in R. (+24)) - (-17
(+24 17)) = (+
(+41
41)).

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 38


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.19
Two integers A and B are stored in two’s complement format
format..
Show how B is subtracted from A.

A = (11011101
11011101))2 B = (00010100
00010100))2

Solution
The operation is subtracting
subtracting.. A is added to (B + 1) and the result
is stored in R. (−
(−35
35)) − (+20)) = (−
(+20 (−55
55)).

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 39


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.20
Two integers A and B are stored in two’s complement format
format.. Show
how B is added to A.
A = (01111111
01111111))2 B = (00000011
00000011))2
Solution
The operation is adding
adding.. A is added to B and the result is stored in R.

130,, but the answer is −126


We expect the result to be 127 + 3 = 130 126.. The error is
due to overflow, because the expected answer (+ 130)) is not in the range −128
(+130
to +127
127..
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 40


19-Apr-16
SWISS GERMAN UNIVERSITY

i
When we do arithmetic operations on numbers in a
computer, we should remember that each number
and the result should be in the range defined by
the bit allocation.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 41


19-Apr-16
SWISS GERMAN UNIVERSITY

sign-and-magnitude integers
Addition and subtraction for integers in sign-and-magnitude
representation looks very complex. We have four different
combination of signs (two signs, each of two values) for addition
and four different conditions for subtraction. This means that we
need to consider eight different situations. However, if we first check
the signs, we can reduce these cases, as shown in Figure 4.7.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 42


19-Apr-16
SWISS GERMAN UNIVERSITY

Addition and subtraction of integers in sign-and-magnitude format QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 43


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.22
Two integers A and B are stored in sign
sign--and
and--magnitude format
format..
Show how B is added to A.
A = (0 0010001
0010001))2 B = (1 0010110
0010110))2
Solution
The operation is adding
adding:: the sign of B is not changed
changed.. S = AS XOR BS = 1; RM =
AM + (BM +1). Since there is no overflow, we need to take the two’s
complement of RM. The sign of R is the sign of B. (+ 17)) + ( −22
(+17 22)) = (−
(−55 ).

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 44


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.23
Two integers A and B are stored in sign
sign--and
and--magnitude format
format..
Show how B is subtracted from A.
A = (1 1010001
1010001))2 B = (1 0010110
0010110))2
Solution
The operation is subtracting
subtracting:: SB = SB. S = AS XOR BS = 1, RM = AM + (BM
+1). Since there is an overflow, the value of RM is final
final.. The sign of R is the
sign of A. (−
(−81
81)) − (−
(−22
22)) = (−
(−59
59)).

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 45


19-Apr-16
SWISS GERMAN UNIVERSITY

Arithmetic operations on reals


All arithmetic operations such as addition, subtraction,
multiplication and division can be applied to reals stored in floating-
point format. Multiplication of two reals involves multiplication of
two integers in sign-and-magnitude representation. Division of two
reals involves division of two integers in sign-and-magnitude
representations. Since we did not discuss the multiplication or
division of integers in sign-and magnitude representation, we will
not discuss the multiplication and division of reals, and only show
addition and subtractions for reals.

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 46


19-Apr-16
SWISS GERMAN UNIVERSITY

Addition and subtraction of reals

Addition and subtraction of real numbers stored in


floating-point numbers is reduced to addition and
subtraction of two integers stored in sign-and-magnitude
(combination of sign and mantissa) after the alignment of
decimal points. Figure 4.8 shows a simplified version of
the procedure (there are some special cases that we have
ignored).

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 47


19-Apr-16
SWISS GERMAN UNIVERSITY

Addition and subtraction of reals in floating-point format QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 48


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.24
Show how the computer finds the result of (+
(+55.75
75)) + (+
(+161
161..875
875))
= (+
(+167
167..625
625)).

Solution
As we saw in Chapter 3, these two numbers are stored in floating
floating--
point format, as shown below, but we need to remember that each
number has a hidden 1 (which is not stored, but assumed)
assumed)..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 49


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.24 (Continued)

The first few steps in the UML diagram (Figure 4.8) are not
needed.. We de
needed de--normalize the numbers by adding the hidden 1s to
the mantissa and incrementing the exponent
exponent.. Now both de de--
normalized mantissas are 24 bits and include the hidden 1s. They
should be stored in a location that can hold all 24 bits
bits.. Each
exponent is incremented
incremented..

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 50


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.24 (Continued)


Now we do sign
sign--and
and--magnitude addition, treating the sign and
the mantissa of each number as one integer stored in sign
sign--and
and--
magnitude representation
representation..

There is no overflow in the mantissa, so we normalize


normalize..

The mantissa is only 23 bits, no rounding is needed needed.. E =


(10000110
10000110))2 = 134 M = 0100111101
0100111101.. In other words, the result is
0100111101))2 × 2134
(1.0100111101 134−−127 = (10100111
10100111..101
101))2 = 167
167..625
625..
QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 51


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.25
Show how the computer finds the result of (+
(+55.75
75)) +
(−77.0234375
(− 0234375)) = − 1.2734375
2734375..
Solution
These two numbers can be stored in floating
floating--point format, as
shown below
below::

De--normalization results in
De in::

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 52


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.25 (Continued)

Alignment is not needed (both exponents are the same), so we


apply addition operation on the combinations of sign and
mantissa.. The result is shown below, in which the sign of the
mantissa
result is negative
negative::

Now we need to normalize


normalize.. We decrement the exponent three
times and shift the de
de--normalized mantissa to the left three
positions::
positions

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 53


19-Apr-16
SWISS GERMAN UNIVERSITY

Example 4.25 (Continued)

The mantissa is now 24 bits, so we round it to 23 bits


bits..

The result is R = − 2127−127 × 1.0100011 = − 1.2734375


127− 2734375,, as
expected..
expected

QF 7.01/REV01

Erikson S.T., M.Kom / Engineering / Bachelor/ IT Fundamental 54


19-Apr-16

You might also like