Beruflich Dokumente
Kultur Dokumente
M. Morris Mano
Data Types Complements Fixed Point Representations Other Binary Codes Error Detection Codes
OUTLINES
Data
Numeric Data
Non-numeric Data
Letters, Symbols
Data Types
Data Structures
Program (Instruction)
Number System
Data Types
NUMERIC DATA REPRESENTATION
Data Types
REPRESENTATION
OF POSITIONAL NUMBERS
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 Decimal to Base R number 1. Separate the number into its integer and fraction parts and convert each part separately. 2. Convert integer part into the base R number successive divisions by R and accumulation of the remainders. 3. Convert fraction part into the base R number
Data Types
CONVERSION OF BASES
Solution:
Integer = 41 41 20 1 10 0 5 0 2 1 1 0 0 1 Fraction = 0.6875 0.6875 x 2 1.3750 x 2 0.7500 x 2 1.5000 x 2 1.0000 (0.6875)10 = (0.1011)2
Data Types
CONVERSION OF BASES (Example)
(41)10
= (101001)2
(41.6875)10 = (101001.1011)2
Two types of complements for base R number system: - R's complement and (R-1)'s complement
COMPLEMENTs
Complement
Signed magnitude:
Take the 2's complement of the number, including its sign bit.
Example: Represent +9 and -9 in 7 bit-binary number Only one way to represent +9 ==> 0 001001 Three different ways to represent -9: In signed-magnitude: 1 001001 In signed-1's complement: 1 110110 In signed-2's complement: 1 110111 Dept. of Computer Science Engineering Islamic Azad University of Mashhad
10
Max: 2n . 2-m 011 ... 11.11 ... 1 Min: -(2n . 2-m) 111 ... 11.11 ... 1 Zero: +0 000 ... 00.00 ... 0 -0 100 ... 00.00 ... 0
(cont)
Signed 1s Complement
Max: 2n . 2-m Min: -(2n . 2-m) Zero: +0 -0 011 ... 11.11 ... 1 100 ... 00.00 ... 0 000 ... 00.00 ... 0 111 ... 11.11 ... 1
Signed 2s Complement
Max: 2n . 2-m Min: -2n Zero: 0 011 ... 11.11 ... 1 100 ... 00.00 ... 0 000 ... 00.00 ... 0 11
Compare their signs If two signs are the same , ADD the two magnitudes - Look out for an overflow If not the same , compare the relative magnitudes of the numbers and then SUBTRACT the smaller from the larger --> need a subtractor to add Determine the sign of the result
3.
Fixed Point Representations ARITHMETIC ADDITION: SIGNED MAGNITUDE
4.
12
6+9 6 +) 9 15
Fixed Point Representations ARITHMETIC ADDITION: SIGNED MAGNITUDE (Example)
-6 + 9 0110 1001 1111 -> 01111 9 -)6 3 1001 0110 0011 -> 00011
-6 + (-9)
13
Add the two numbers, including their sign bit, and discard any carry out of leftmost (sign) bit - Look out for an overflow
-6 +) 9 3 1 1010 0 1001 0 0011
cn-1 cn
14
If there is a carry out of the most significant (sign) bit, the result is incremented by 1 and the carry is discarded.
6 -9 -3 0 0110 1 0110 1 1100
end-around carry -6 1 1001 +) 9 0 1001 (1) 0(1)0010 1 +) 3 0 0011 not overflow (cn-1 9 0 1001 9 0 1001 1 (1)0010
+)
cn) = 0
+) +)
+)
overflow
(cn-1 cn) 15
* Easiness of negative conversion S + M > 1s Complement > 2s Complement * Hardware - S+M: Needs an adder and a subtractor for Addition - 1s and 2s Complement: Need only an adder
Fixed Point Representations
COMPARISON OF REPRESENTATIONS
* Recognition of Zero
2s Complement is fast
16
Another Computer
External Representation
External Representation
Internal Representation
Human
CPU Memory
Device
External Representation
17
Numbers
Most of numbers stored in the computer are eventually changed by some kinds of calculations
EXTERNAL REPRESENTATION
No needs for Internal Representation since they are not used for calculations External Representation for processing and presentability
18
Note: 8,4,2,-2,1,-1 in this table is the weight associated with each bit position.
Decimal BCD(8421) 2421 84-2-1 Excess-3
EXTERNAL REPRESENTATION
DECIMAL CODES
0 1 2 3 4 5 6 7 8 9
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
0000 0001 0010 0011 0100 1011 1100 1101 1110 1111
0000 0011 0111 0100 0110 0101 0101 0110 0100 0111 1011 1000 1010 1001 1001 1010 1000 1011 1111 1100
19
Gray Code
gi = bi bi+1 gn = bn and
, 0 i n-1
LSB (4 bits)
Null Start of Heading (CC) Start of Text (CC) End of Text (CC) End of Transmission (CC) Enquiry (CC) Acknowledge (CC) Bell Backspace (FE) Horizontal Tab. (FE) Line Feed (FE) Vertical Tab. (FE) Form Feed (FE) Carriage Return (FE) Shift Out Shift In Data Link Escape (CC)
DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US DEL
Device Control 1 Device Control 2 Device Control 3 Device Control 4 Negative Acknowledge (CC) Synchronous Idle (CC) End of Transmission Block (CC) Cancel End of Medium Substitute Escape File Separator (IS) Group Separator (IS) Record Separator (IS) Unit Separator (IS) Delete
22
Parity System
Simplest method for error detection One parity bit attached to the information Even Parity and Odd Parity
Even Parity
ERROR DETECTING CODES
One bit is attached to the information so that the total number of 1 bits is an even number 1011001 0 1010010 1 One bit is attached to the information so that the total number of 1 bits is an odd number 1011001 1 1010010 0
23
Odd Parity
beven
b0
Parity Checker
beven b6 b5 b4 b3 b2 b1 b0
24