Data Representation (V) For SMJE3093
Data Representation (V) For SMJE3093
Computer Systems
William Stallings (2016). Computer Organization and Architecture: Designing for Performance (10th Edition). United States: Pearson Education Limited, p.368. 3
Data Representation in
Computer Systems
5
32-bit multiplicand starts at right
half of multiplicand register
Multiplicand
Shift left
64 bits
Multiplier
64-bit ALU Shift right
32 bits
Product
Control test
Write
64 bits
Yes: 32 repetitions
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The
Done
Hardware/Software Interface (5th Edition). United States: Elsevier, p.185. 7
Start
Example 14:
Multiplier0 = 1 1. Test Multiplier0 = 0
Using 4-bit numbers, Multiplier0
00102 x 00112
Multiplier (MP)
Steps:
3. Shift the Multiplier register right 1 bit
1 – Test multiplier (0 or 1)
If 1 then 1a: P = P + MC
If 0 then no operation Max bit = Number of
2 – Shift MC left iteration.
32nd repetition?
No: < 32 repetitions
3 – Shift MP right f
All bits done? → Based on
Yes: 4-bits
32 repetitions
If still <max bit, repeat
If = max bit, stop
number system used.
Done
8
210 x 310 = _______10
Iteration Step Multiplier (MP) Multiplicand (MC) Product (P)
In 4-bit binary arithmetic, find the multiplication of 510 with 410 using
the 1st version of highly optimized multiplication hardware.
10
Solution 2.2:
Iteration Step Multiplier (MP) Multiplicand (MC) Product (P)
0 Initial value
1 2: Shift MC left
3: Shift MP right
2 2: Shift MC left
3: Shift MP right
3 2: Shift MC left
3: Shift MP right
4 2: Shift MC left
3: Shift MP right
11
Aside:
◼ Examples:
Linda Null and Julia Lobur (2003). The Essentials of Computer Organization and Architecture. United States: Jones and Bartlett Publishers. p.53. 12
Example 15:
Using a 4-bit binary arithmetic, multiply 210 with (–310) using the 1st
version of highly optimized multiplication hardware.
Solution:
→
▪ Do an additive inverse to the multiplicand (MC) and the MP:
13
(- 210) x 310 = _______10
Iteration Step Multiplier (MP) Multiplicand (MC) Product (P)
1 2: Shift MC left
3: Shift MP right
2 2: Shift MC left
3: Shift MP right
3 2: Shift MC left
3: Shift MP right
4 2: Shift MC left
14
3: Shift MP right
Exercise 2.3:
15
Solution 2.3:
Iteration Step Multiplier (MP) Multiplicand (MC) Product (P)
0 Initial value 001110 0000 0001 0101 0000 0000 0000
1 2: Shift MC left
3: Shift MP right
2 2: Shift MC left
3: Shift MP right
3 2: Shift MC left
3: Shift MP right
4 2: Shift MC left
3: Shift MP right
16
Iteration Step Multiplier (MP) Multiplicand (MC) Product (P)
2: Shift MC left
5
3: Shift MP right
2: Shift MC left
6
3: Shift MP right
17
(d) Division
William Stallings (2013). Computer Organization and Architecture: Designing for Performance (9th Edition). United States: Pearson Education Limited, p.360. 18
◼ Another way to express the relationship between the
components:
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.193. 19
(d) Division
Unsigned Integer
(13)
(11) (147)
(4)
William Stallings (2016). Computer Organization and Architecture: Designing for Performance (10th Edition). United States: Pearson Education Limited, p.348. 20
(d) Division
Signed Integer: Two’s Complement
◼ The rules:
▪ In the next slides, assume that both the dividend and divisor
are positive number; Hence the quotient and remainder are
non-negative.
23
32-bit divisor starts at left half of divisor register
Divisor
Shift right Quotient register is
initialized to be 0
64 bits
Quotient
64-bit ALU Shift left
32 bits
Remainder Control
Write test
64 bits
2a. Shift the Quotient register to the left, 2b. Restore the original value by adding
setting the new rightmost bit to 1 the Divisor register to the Remainder
register and place the sum in the
Remainder register. Also shift the
Quotient register to the left, setting the
new least significant bit to 0
Yes: 33 repetitions
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Done
Hardware/Software Interface (5th Edition). United States: Elsevier, p.191. 25
Start
Steps:
1 – Remainder (R) = R – D
2 – test new R 3. Shift the Divisor register right 1 bit
Max bit + 1 =
2a - If >=0 then Shift left Q (add 1 at LSB)
2b - If <0 then R = D + R, Shift left Q (add 0 at LSB) Number of iteration.
3 – shift D right 33rd repetition? f
No: < 33 repetitions
Quotient
Iteration Steps (Q) Divisor (D) Remainder (R)
0 Initial value 0000 0010 0000 0000 0111
1 :R=R–D 1110 0111
1
3 : D = Shift right
R=R–D
1 :R=R–D
= R + (–D)
2
0000 0111 (7)
3 : D = Shift right
+ 1110 0000 (2’s for D)
1 :R=R–D
1110 0111
3
3 : D = Shift right
27
Divisor start at left half
7 / 2 = ____ of divisor register !
Quotient
Iteration Steps (Q) Divisor (D) Remainder (R)
0 Initial value 0000 0010 0000 0000 0111
1 :R=R–D 1110 0111
2b: R < 0; R = D+R 0000 0111
1
Q : Shift Left (+0) 0000
3 : D = Shift right 0001 0000
1 :R=R–D 1111 0111
2b: R < 0; R = D+R 0000 0111
2
Q : Shift Left (+0) 0000
3 : D = Shift right 0000 1000
1 :R=R–D 1111 1111
2b: R < 0; R = D+R 0000 0111
3 Q : Shift Left (+0) 0000
3 : D = Shift right 0000 0100
28
Try to complete the table for the remaining iterations:
R = 0000 01112; Q = 00002; D = 0000 01002
Quotient
Iteration Steps (Q) Divisor (D) Remainder (R)
1 :R=R–D 0000 0011
2a: No Operation
4
Q : Shift Left (+1) 0001
3 : D = Shift right 0000 0010
1 :R=R–D 0000 0001
2a: No Operation
5
Q : Shift Left (+1) 0011
3 : D = Shift right 0000 0001
Answer: 7 / 2 = 3 remainder 1
29
Exercise 2.5:
Using a 4-bit binary arithmetic, find the division of (–710) by 210 with
the 1st version of highly optimized division hardware.
30
Exercise 2.6:
31
Data Representation in
Computer Systems
33
The IEEE-754 Floating-point Standard
(IEEE) Institute of Electrical and Electronic Engineers
Floating-points
William Stallings (2013). Computer Organization and Architecture: Designing for Performance (9th Edition). United States: Pearson Education Limited, p.331. 34
MIPS (Millions of Instructions Per Second)
Overview
◼ General form:
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.197. 35
MIPS (Millions of Instructions Per Second)
◼ Solution:
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.198. 37
(b) Double Precision
o Smallest fraction:
o Largest number:
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.198. 38
The IEEE-754 Floating-point Standard
Representation
◼ Significant : 1 + fraction
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.199. 40
The IEEE-754 Floating-point Standard
Normalized & Unnormalized
◼ Examples:
41
Exercise 2.11:
Complete the table with the normalized binary number and its
exponent respectively using single precision floating-point.
42
Biased Notation
0 11111111 00000000000000000000000
Sign Exponent significand / fraction
43
Bias values, B = (2n – 1) – 1 :
EB = e’ + Bias
◼ Example: = (–1) + 127
= 12610 = 01111 11102
1.02 x 2–1
0 01 1 1 1 1 1 1 01 01 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Sign Biased
Exponent
Exponent significand / fraction
44
/ Single-Precision / Single word
William Stallings (2013). Computer Organization and Architecture: Designing for Performance (9th Edition). United States: Pearson Education Limited, p.331. 45
Exercise 2.12:
Complete the table with the biased exponent (EB) and binary
representation for each number using the type of floating-point
respectively.
o Step 1: Normalized.
47
Example 20:
= 1.01001102 x 20+3
0.4 x 2 = 0.8
0.8 x 2 = 1.6 = 1.01001102 x 23
0.6 x 2 = 1.2
0.2 x 2 = 0.4
.....
(Repetitive Multiplication)
0 10000010 01001100000000000000000
Sign Biased Exponent significand / fraction
49
Exercise 2.13:
0 01111110 10000000000000000000000
Sign Biased Exponent significand / fraction
50
Exercise 2.14:
51
Exercise 2.15:
Complete the table with all sign (S), exponent (e’) and fraction (F)
values if single precision floating-point applied.
(Decimal) (Binary)
52
Exercise 2.16:
53
The IEEE-754 Floating-point Standard
Conversion of Binary Floating-point to Decimal
54
Example 21:
1 10000001 01000000000000000000000
Solution:
0 01111111110 00100000000000000...0
57
Data Representation in
Computer Systems
William Stallings (2013). Computer Organization and Architecture: Designing for Performance (9th Edition). United States: Pearson Education Limited, p.334. 59
Addition
Flows
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The
Hardware/Software Interface (5th Edition). United States: Elsevier, p.205. 60
◼ Assume 4 decimal digits for fraction and 2 decimal digits for
exponent.
61
Add these two decimal floating-point
numbers. Assume that we can store only
four decimal digits of the significand and
Example 22:
two decimal digits of the exponent.
Solution:
◼ Step 1: Align the decimal ◼ Step 2: Add the fraction.
point of the number that has
the smaller exponent.
9.9990 x 101
1.61010 x 10–1
+ 0.0161 x 101
= 1.61010 x 10–1 x 102
10.0151 x 101
= 0.016110 x 101
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.203. 62
◼ Step 3: Normalize the sum.
10.0151 x 101 → 1.00151 x 102
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.203. 63
Example 23:
(– 0.01112 x 20)x 2– 2
(0.12 x 20) x 2– 1
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.204. 64
◼ Step 1: Align the decimal ◼ Step 3: Normalize the sum.
point of the number that has
the smaller exponent. 0.001 x 2–1 x 2–3 → 1.0 x 2–4
– 1.112 x 2–2
= – 1.112 x 2–2 x 21
◼ Step 4: Round the fraction
= – 0.1112 x 2–1 (to 4 decimal digits for
fraction).
◼ Step 2: Add the fraction.
1.0 x 2–4 → 1.0000 x 2–4
1.000 x 2–1
+ – 0.111 x 2–1
0.001 x 2–1
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.204. 65
◼ Step 5: Normalize it (if need be).
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The Hardware/Software Interface (5 th Edition). United States: Elsevier, p.204. 66
Exercise 2.18:
67
Exercise 2.19:
1 1 1 1 0 1 0 1 0 0 ….. 0 0 0
0 1 0 1 0 0 1 1 0 0 ….. 0 0 0
68
Multiplication
Flows
Patterson, D.A. and Hennessy, J.L. (2014). Computer Organization and Design: The
Hardware/Software Interface (5th Edition). United States: Elsevier, p.209. 69
◼ Assume 4 decimal digits for fraction and 2 decimal digits for
exponent.
70
Example 24:
Solution:
10212000
71
◼ Step 3: Normalize the product.
10.2120 x 105 x 101 → 1.02120 x 106
+1.0212 x 106
72
Example 25:
Solution:
1110000
73
◼ Step 3: Normalize the product.
Already normalized
–1.1100 x 2–3
Exercise 2.20:
75
2.6 Summary
Linda Null and Julia Lobur (2003). The Essentials of Computer Organization and Architecture. United States: Jones and Bartlett Publishers. p.83. 76