lOMoARcPSD| 59994889
fit@hcmus
4.0
REVIEW #
1
DATA REPRESENTATION
CSC10009
Computer System
lOMoARcPSD| 59994889
2
)
fit@hcmus
Value
(
Positional) Number Systems
General
formular
for
unsigned
integer
with
n
digits
in
q
-
base
system
Binary number system (base
-
2)
Octal number system (base
-
8)
Decimal number system (base
-
10)
Hexadecimal number system (base
-
16)
Exponential Form
x
n
-
1
MSB
:
)
Most Significant Bit
(
x
0
:
LSB
)
Less Significant Bit
(
lOMoARcPSD| 59994889
3
)
fit@hcmus
Sign Extension
Positive
number
16
-
bit
to
-
bit
Negative
number
-
bit
to
32
-
bit
lOMoARcPSD| 59994889
4
)
fit@hcmus
Integer Representation
One’s Complement
2
n
-
1
-
1
2
n
-
1
-
2
n
-
1
+1
-
2
n
-
1
lOMoARcPSD| 59994889
5
)
fit@hcmus
Integer Representation (2)
Signed
integer
A
of
n
-
bit
in
2
’s
Complement
representation
:
lOMoARcPSD| 59994889
6
)
fit@hcmus
Shift & Rotate
lOMoARcPSD| 59994889
7
)
fit@hcmus
Shift & Rotate (2)
or
lOMoARcPSD| 59994889
8
)
fit@hcmus
Shift & Rotate (3)
Clear a bit (AND with 0 is always 0)
Set a bit (OR with 1 is always 1)
Flip a bit (XOR with 1 = flip that bit)
:
Get the value at bit i of x
:
Set bit i of x to
1
:
Set bit i of x to
0
:
Flip bit i of x
lOMoARcPSD| 59994889
9
)
fit@hcmus
Addition (Unsigned number)
General
Rule
Example
(
5
-
bit,
unsigned
number
)
OVERFLOW:
There is a
carry
-
out
bit from the
most significant bit (MSB).
29
17
lOMoARcPSD| 59994889
10
)
fit@hcmus
Addition (Signed number)
OVERFLOW RULE
:
If two numbers are added, and they are both
positive or both negative, then overflow occurs if and only if
the
result has the opposite sign
.
lOMoARcPSD| 59994889
11
)
fit@hcmus
Subtraction (Signed number)
OVERFLOW RULE
:
If two numbers are added, and they are both
positive or both negative, then overflow occurs if and only if the
result has the opposite sign.
lOMoARcPSD| 59994889
12
)
fit@hcmus
Multiplication (2)
(
Unsigned Number
)
M
(
11
)
x
Q
(
13
)
=
?
lOMoARcPSD| 59994889
13
)
fit@hcmus
Multiplication (3)
(
Signed Number: Booth’s Algorithm
)
M
(
7
)
x
Q
(
3
)
=
?
lOMoARcPSD| 59994889
14
)
fit@hcmus
Division
(
Unsigned Number
)
Q=
7
,
M
=
3
,
Q/M=?
T
R
lOMoARcPSD| 59994889
15
)
fit@hcmus
Division (2)
(
Signed Number
)
T
=
Q/M
;
R
=
Q
%
M
Q
=
7
,
M
=
3
T
=
2
,
R
=
1
Q
=
7
,
M
=
-
3
T
=
-
2
,
R
=
1
Q
=
-
7
,
M
=
3
T
=
-
2
,
R
=
-
1
Q
=
-
7
,
M
=
-
3
T
=
2
,
R
=
-
1
Q
M
T
R
>0
>0
>0
>0
>0
<0
<0
>0
<0
>0
<0
<0
<0
<0
>0
<0
lOMoARcPSD| 59994889
17
Downloaded by Bao Han (hanbao3006@gmail.com)
fit@hcmus
Representation
Convert
decimal
binary
Fixed
-
point Numbers
Integer part
Fraction part
lOMoARcPSD| 59994889
18
Downloaded by Bao Han (hanbao3006@gmail.com)
fit@hcmus
Fixed
-
point Numbers (2)
123.375
10
=
0111 1011
.
0110 0000
2
13.625
10
=
0000 1101
.
101
2
Integer part
Fraction part
lOMoARcPSD| 59994889
19
Downloaded by Bao Han (hanbao3006@gmail.com)
fit@hcmus
Normalized Float Number
±
.
1
F
* 2
E
Exponent
Significand (Fraction)
lOMoARcPSD| 59994889
20
Downloaded by Bao Han (hanbao3006@gmail.com)
fit@hcmus
Normalized Float Number (2)
±
.
1
F
* 2
E
Exponent
Significand (Fraction)
lOMoARcPSD| 59994889
21
Downloaded by Bao Han (hanbao3006@gmail.com)
fit@hcmus
Overflow vs. Underflow
±
.
1
F
* 2
E
Exponent
Significand (Fraction)
Overflow
:
A
positive exponent
becomes too large to fit in the exponent field.
Underflow
:
A
negative exponent
becomes too large to fit in the exponent field.

Preview text:

lOMoAR cPSD| 59994889 CSC10009 – Computer System REVIEW # 1 DATA REPRESENTATION 4.0 fit@hcmus lOMoAR cPSD| 59994889 4.0 ( Positional) Number Systems fit@hcmus
▪ General formular for unsigned integer with n digits in q - base system x n : MSB - 1 x 0: LSB (Most Si gnifican ) t Bit L
( ess Significan ) t Bit Value Exponential Form
Binary number system (base - 2) Octal number system (base - 8)
Decimal number system (base - 10)
Hexadecimal number system (base - 16) 2 ) lOMoAR cPSD| 59994889 4.0 Sign Extension fit@hcmus
▪ Positive number 16 - bit to 32 - bit
▪ Negative number 16 - bit to 32 - bit 3 ) lOMoAR cPSD| 59994889 4.0 Integer Representation fit@hcmus
- 2 n - 1 - 2 n - 1 +1
2 n - 1 - 1
2 n - 1 One’s Complement 4 ) lOMoAR cPSD| 59994889 4.0 Integer Representation (2) fit@hcmus
▪ Signed integer A of n - bit in 2 ’s Complement representation : 5 ) lOMoAR cPSD| 59994889 4.0 Shift & Rotate fit@hcmus 6 ) lOMoAR cPSD| 59994889 4.0 Shift & Rotate (2) fit@hcmus or 7 ) lOMoAR cPSD| 59994889 4.0 Shift & Rotate (3) fit@hcmus
Clear a bit (AND with 0 is always 0)
Set a bit (OR with 1 is always 1)
Flip a bit (XOR with 1 = flip that bit) : Get the value at bit i of x : Set bit i of x to 1 : Set bit i of x to 0 : Flip bit i of x 8 ) lOMoAR cPSD| 59994889 4.0 Addition (Unsigned number) fit@hcmus ▪ General Rule
▪ Example ( 5 - bit, unsigned number ) 29 17
OVERFLOW: There is a carry - out bit from the 9 most significant bit (MSB). ) lOMoAR cPSD| 59994889 4.0 Addition (Signed number) fit@hcmus
OVERFLOW RULE : If two numbers are added, and they are both
positive or both negative, then overflow occurs if and only if
the result has the opposite sign . 10 ) lOMoAR cPSD| 59994889 4.0 Subtraction (Signed number) fit@hcmus
OVERFLOW RULE : If two numbers are added, and they are both
positive or both negative, then overflow occurs if and only if the 11 result has the opposite sign. ) lOMoAR cPSD| 59994889 4.0 Multiplication (2) fit@hcmus
( Unsigned Number ) M ( 11 ) x Q ( 13 ) = ? 12 ) lOMoAR cPSD| 59994889 4.0 Multiplication (3) fit@hcmus
( Signed Number: Booth’s Algorithm ) M ( 7 ) x Q ( 3 ) = ? 13 ) lOMoAR cPSD| 59994889 4.0 Division fit@hcmus
( Unsigned Number ) Q= 7 , M = 3 , Q/M=? R T 14 ) lOMoAR cPSD| 59994889 4.0 Division (2) fit@hcmus
( Signed Number ) T = Q/M ; R = Q % M Q  = 7 , M = 3 T = 2 , R = 1 Q  = 7 , M = - 3 T = - 2 , R = 1 Q  = - 7 , M = 3 T = - 2 , R = - 1 Q  = - 7 , M = - 3 T = 2 , R = - 1 Q M T R >0 >0 >0 >0 >0 <0 <0 >0 <0 >0 <0 <0 <0 <0 >0 <0 15 ) lOMoAR cPSD| 59994889 4.0 Fixed-point Numbers fit@hcmus ▪ Representation Integer part Fraction part
▪ Convert decimal  binary 17
Downloaded by Bao Han (hanbao3006@gmail.com) lOMoAR cPSD| 59994889 4.0 Fixed-point Numbers (2) fit@hcmus Integer part Fraction part 123.375 10 = 0111 1011 . 0110 0000 2 13.625 10 = 0000 1101 . 101 2 18
Downloaded by Bao Han (hanbao3006@gmail.com) lOMoAR cPSD| 59994889 4.0 Normalized Float Number fit@hcmus ± E . 1 F * 2 Significand (Fraction) Exponent 19
Downloaded by Bao Han (hanbao3006@gmail.com) lOMoAR cPSD| 59994889 4.0 Normalized Float Number (2) fit@hcmus ± E . 1 F * 2 Significand (Fraction) Exponent 20
Downloaded by Bao Han (hanbao3006@gmail.com) lOMoAR cPSD| 59994889 4.0 Overflow vs. Underflow fit@hcmus ± E . 1 F * 2 Significand (Fraction) Exponent
 Overflow : A positive exponent becomes too large to fit in the exponent field.
 Underflow : A negative exponent becomes too large to fit in the exponent field. 21
Downloaded by Bao Han (hanbao3006@gmail.com)