Chapter 3 (Comp. Arch)
Chapter 3 (Comp. Arch)
Chapter 3 (Comp. Arch)
ELE5361
DATA REPRESENTATION*
3.2 Complements
* Note: These slides were adapted from Prof. Hyunsoo Yoon, CS. Dept. KAIST
Computer Arch. &Org.
Data Representation 2 Data Types
DATA REPRESENTATION
NUMERIC DATA
DataREPRESENTATION
Numeric data - numbers(integer, real)
Non-numeric data - symbols, letters
Number System
Nonpositional number system
-Roman number system
Positional number system
- Each digit position has
a value called a weight
associated with it
- Decimal, Octal, Hexadecimal, Binary
Base (or radix) R number
- Uses R distinct symbols for each digit
- Example AR = an-1 an-2 ... a1 a0 .a-1…a-m
i Radix point(.) separates the integer
- V(AR ) = ai R portion and the fractional portion
CONVERSION OF BASES
Base R to Decimal Conversion
A = an-1 an-2 an-3 … a0 . a-1 … a-m
V(A) = ak Rk
(736.4)8 = 7 x 82 + 3 x 81 + 6 x 80
+ 4 x 8-1
= 7 x 64 + 3 x 8 + 6 x 1 + 4/8 =
(478.5)10
(110110)2 = ... = (54)10
(110.111)2 = ... = (6.785)10
(F3)16 = ... = (243)10
(0.325)6 = ... =
(0.578703703 .................)10
EXAMPLE
Fraction = 0.6875
Convert 41.6875 10 to base 2.
0.6875
Integer = 41 x 2
41 1.3750
20 1 x 2
10 0 0.7500
5 x 2
0 1.5000
2 x 2
1 1.0000
1
(41)10 = (101001)2 (0.6875)10 = (0.1011)2
0
0
1 (41.6875)10 = (101001.1011)2
Exercise
Convert (63)10 to base 5: (223)5
Convert (1863)10 to base (3507)8
Convert (0.63671875)10
8: to hexadecimal: (0.A3)16
COMPLEMENT OF NUMBERS
Example
- 10's complement of 83510 is 16410 + 1 = 16510
- 2's complement of 10102 is 01012 + 1 = 01102
Computer Arch. &Org.
Data Representation
9 Fixed Point Representations
FIXED POINT NUMBERS
Numbers: Fixed Point Numbers and Floating Point
Numbers
2 ... x-m)
SIGNED NUMBERS
- Following 3 representations
X = xn xn-1 ... x0
n-1
+
V(X) = - xn 2n x2
i=0
i
i
Example
6 0 0110 -6 1 1010
+) 9 0 1001 +) 9 0 1001
15 0 1111 3
0011
6 0 0110 -9 x’n-1y’n-1sn-1
(cn-1 cn)
9 0 1001 overflow1
+) 9 0 1001 2 operands have the same sign
18 1 0010 and the result sign changes
0111
+) -9 1 0111 xn-1 yn s’ n-1 +) -9
xn-1yn-1s’n-1 + x’n-1y’n-1sn-1 = cn-1
cn )
(cn-1
-9 1 0110 9 0 1001
+) -9 1 0110 +) 9 0 1001
(1)0 1100 1
+) 1 (1)0010
0 1101
overflow
(cn-1 cn)
* Speed of Arithmetic
ARITHMETIC SUBTRACTION
(A)-(-B) =(A)+ B
(A)- B=(A)+( -B)
F = EM
mn ekek-1 ... e0 … m0 . m-1 … m
mn-1mn-2 -m
sign exponent mantissa
- Mantissa
Signed fixed point number, either an integer or a fractional number
- Exponent
Designates the position of the radix point
Decimal Value
Example
A binary number +1001.11 in 16-bit floating point number representation
(6-bit exponent and 10-bit fractional mantissa)
0 0 00100 100111000
Sign Exponent Mantissa
or
0 0 00101
010011100
Representation of Zero
- Zero
Mantissa = 0
- Real Zero
Mantissa = 0
Exponent
= smallest representable number
which is represented as
00 ... 0
Easily identified by the
hardware
Computer Arch. &Org.
Data Representation 21
INTERNAL REPRESENTATION AND EXTERNAL REPRESENTATION
Another
Computer External
Representation
External
Internal
Representation Human
Representation
CPU
Memory
External
Representation
Device
BCD: d3 x 8 + d2 x 4 + d1 x 2 + d0 x 1
8421 code.
2421:
d3 x 2 + d2 x 4 + d1 x 2 + d0 x 1
84-2-1: d3 x 8 + d2 x 4 + d1 x (-2) +
d0 x (-1)
Excess-3: BCD + 3
Computer BCD:
Arch. &Org. It is difficult to obtain the 9's complement.
Data Representation 24 Other Binary codes
GRAY CODE
* Characterized by having their representations of the binary integers differ
in only one digit between consecutive integers
* Useful in some applications
gi = , 0 i n-
bi+1
bi 1
Reflection of Gray codes
gn =
0 0 0 0 00 0 000
bnband= gn gn-1 . . . gn-i 1 0 1 0 01 0 001
n-i
bn = gn 1 1 0 11 0 011
1 0 0 10 0 010
1 10 0 110
1 11 0 111
1 01 0 101
Note: 1 00 0 100
1 100
The Gray code has a reflection property 1 101
1 111
- easy to construct a table without calculation,
1 010
- for any n: reflect case n-1 about a 1 011
mirror at its bottom and prefix 0 and 1 1 001
1 101
to top and bottom halves, respectively 1 000
MSB (3 bits)
0 1 2 4 5 6 7
3
LSB 0 NUL DLE SP 0 @ P . p
(4 bits) 1 SOH DC1 ! 1 A Q a q
2 STX DC2 “ 2 B R b r
3 ETX DC3 # 3 C S c s
4 EOT DC4 $ 4 D T d t
5 ENQ NAK % 5 E U e u
6 ACK SYN & 6 F V f v
7 BEL ETB ‘ 7 G W g w
8 BS CAN ( 8 H X h x
9 HT EM ) 9 I Y I y
A LF SUB * : J Z j z
B VT ESC + ; K [ k {
C FF FS , < L \ l |
D CR GS - = M ] m }
E SO RS . > N ^ n ~
F SI US / ? O _ o DEL
Parity System
- Simplest method for error detection
- One parity bit attached to the information
- Even Parity and Odd Parity
Even Parity
- One bit is attached to the information so that
the total number of 1 bits is an even
number
1011001 0
1010010 1
Odd Parity
- One bit is attached to the information so that
the total number of 1 bits is an odd number
1011001 1
1010010 0
beven = b6 b5 ... b0
bodd = beven 1 =
beven
b4
b3
b2
b
Parity Checker
1
b0
beven
b6
b5
b4
Even Parity
b3
error indicator
b2
Computer Arch. &Org.