COA Chapter 02 Part 3
COA Chapter 02 Part 3
Computer
Arithmetic and
Digital Logic
These slides are being provided with permission from the copyright for CS2208
1 use only. The slides must not be reproduced or provided to anyone outside of
the class.
All download copies of the slides are for personal use only.
Students must destroy these copies within 30 days after receipt of final course
evaluations.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
36
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
37
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
38
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
Normalization
A number is called normalized when it is written in scientific notation
with a single non-zero digit before the radix point (i.e., the integer
part consists of a single non-zero digit).
Example 1:
The number 123.45610 is not normalized, as the integer part is not a
single non-zero digit.
To normalize it, you need to move the decimal point two position to
the left and to compensate this move by multiplying the number by
100, i.e.,
1.2345610 × 102
Example 2:
The number 0.0012310 is not normalized, as the integer part is not a
single non-zero digit.
To normalize it, you need to move the decimal point three position to
the right and to compensate this move by dividing the number by
1000, i.e.,
1.2310 × 10-3
39
In base b, a normalized number will have the form ± b0 . b1 b2 b3... × bn
where b0 ≠ 0, and b0, b1, b2, b3 ... are integers between 0 and b -1
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
Floating-point Numbers
Floating-point arithmetic lets you handle the very large and very small
values found in scientific applications.
Floating-point is also called scientific notation, because scientists use it
to represent large numbers (e.g., 1.2345 × 1020) and small numbers that
are very close to zero, but not zero (e.g., 0.45679999 × 10-50).
A floating-point value is encoded as two components: a number and
an adjustment to the location of the radix point within the number.
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
Suppose an 8-bit exponent is used and all exponents are biased by 127.
o If the true exponent is 0, it will be encoded as 0 + 127 = 127.
o If the true exponent is –2, it will be encoded as –2 + 127 = 125.
o If the true exponent is +2, it will be encoded as +2 + 127 = 129.
42
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
When 1 ≤ E ≤ 254,
the significand =
1 + the fractional significand F
43
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
45
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
If E ≠ 0, True exponent =
biased exponent – bias
Biased
values If E = 0, True exponent =
} 0 – (bias – 1)
Unbiased
} values
The book flipped the meaning of S. It is S=0 for +ve and =1 for –ve.
In the IEEE single precision representation,
1 254 for NORMALIZED numbers
the largest normalized absolute number is
46 +38.
2+127 × 1.111…12 ≈ 2+128 = 10+38.5318394 ≈ 3.4×10
the smallest normalized absolute number is
When E = 255 2-126New
× content
1.000…0 2=2
This slide is modified from the original slide by the author A. Clements and used with permission. added and -126 = 10by
copyrighted -37.9297794
© Mahmoud ≈R.1.17×10
El-Sakka. -38.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
52
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
o Hence the number will be 1.000 0000 0000 0000 0000 0001 112 × 2 -129
o As the exponent is less than –126, the fractional part can NOT be
represented as a normalized number (the number is too small)
o Instead, we will attempt to represent it as
an un-normalized underflow number with exponent = –126
o The number = 0.001 0000 0000 0000 0000 0000 0011 12 × 2 -126
o As F is un-normalized the biased exponent will be
the true exponent plus 127 – 1;
that is, –126 + 127 – 1 = 0; Hence, E = 0000 00002 Rounded to
the nearest
o The encoded F value (23 bits) will be 001 0000 0000 0000 0000 0000
56
o The final number is 0000 0000 0001 0000 0000 0000 0000 00002,
or 0010000016.
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
o Hence the number will be 1.111 1111 1111 1111 1111 1111 0112× 2127
o The biased exponent is the true exponent plus 127;
that is, 127 + 127 = 254; Hence, E = 1111 11102
o To encode the F value, we will ignore the leading 1 and
we will only consider the first 23 bits after the binary point, i.e.,
111 1111 1111 1111 1111 1111
Rounded to
the nearest
o The final number is 0111 1111 0111 1111 1111 1111 1111 11112,
or 7F7FFFFF16.
59
o This number is the largest positive normalized number
(3.4028235×10+38)
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.
Computer Organization and Architecture: Themes and Variations, 1st Edition Clements
Due to the used decimal
precision, both numbers looks
the same, but they are not.
The 32-bit IEEE-754 FP Due to the used decimal
precision, both numbers looks
the same, but they are not.
S=1 S=1 S=0 S=0
E=1 (true exp.=-126) E=0 (true exp.=-126) E=0 (true exp.=-126) E=1 (true exp.=-126)
F=0x000000 F=0x7FFFFF F=0x7FFFFF F=0x000000
The step-size between consecutive floating-point numbers is NOT always constant as in integer numbers. 62
To compare two floating-point values without fully decode them, you need to compare S, E, and then F values in order.
This slide is modified from the original slide by the author A. Clements and used with permission. New content added and copyrighted by © Mahmoud R. El-Sakka.