Professional Documents
Culture Documents
(DLD)
Lecture # 3
Sign bit
Signed-magnitude system.
Signed-complement system.
Sign
Signbit
bit 00 positive
positive
Sign
Signbit
bit 11 negative
negative
the
same
magnitude
bits
as
the
01001
11001
+9
9
Example
Example22
3-bit binary pattern
Bit Pattern
000
001
010
011
100
101
110
111
Signed-Magnitude
Decimal Value
+0
+1
+2
+3
-0
-1
-2
-3
5
1S COMPLEMENT
The1'
complementof
abinary numberis
EXAMPLE
2S COMPLEMENT
2' complement
add 1 in it
2' complement
1010
+1
1011
9
Bit Pattern
000
001
010
011
100
101
110
111
Signed 1s complement
decimal value
+0
+1
+2
+3
-3
-2
-1
-0
Signed 2s complement
decimal value
+0
+1
+2
+3
-4
-3
-2
-1
10
Positive values
Negative values
Value
Sign-andMagnitude
1s
Comp.
2s
Comp.
Value
Sign-andMagnitude
1s
Comp.
2s
Comp.
+7
+6
+5
+4
+3
+2
+1
+0
0111
0110
0101
0100
0011
0010
0001
0000
0111
0110
0101
0100
0011
0010
0001
0000
0111
0110
0101
0100
0011
0010
0001
0000
-0
-1
-2
-3
-4
-5
-6
-7
-8
1000
1001
1010
1011
1100
1101
1110
1111
-
1111
1110
1101
1100
1011
1010
1001
1000
-
1111
1110
1101
1100
1011
1010
1001
1000
11
COMPLEMENT OF FRACTIONS
Examples:
12
13
ADDITION
14
15
BINARY SUBTRACTION
Have previously looked at the subtraction
operation. A quick review.
Just like subtraction in any other base
Minuend
Subtrahand
Difference
10110
- 10010
00100
16
17
BINARY MILTIPLICATIN-RULES
0*0=0
0*1=0
1*0=0
1*1=1
18
BINARY MILTIPLICATIN
19
BINARY DIVISION
20
BINARY CODES
THE 8421 BCD
THE EXCESS-3 CODE
SELF COMPLEMENTING CODES
21
BCD
One can store two digits per byte, called "packed" BCD
22
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
ote: 1010, 1011, 1100, 1101, 1110, and 1111 are INVALID CODE!
23
B.C.D.
Example:
Example:
24
Question
Convert the BCD coded number
1000 0111 0001 into decimal.
1
25
BCD ADDITION
Add the two BCD numbers, using the rules for basic binary addition.
2.
3.
4+5
4+8
+
184+576
1
+
184
576
760
28
Sample Problem:
Decimal
Excess-3
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
30
8421 code
84-2-1
0101=0x8+1x4+0x2+1x1=5
0101=0x8+1x4+0x(-2)+1x(-1)=3
31
Unweighted Code
Only a single bit change from one code value to the next.
Example: 4-bit standard Gray code
Decimal
0
1
2
3
4
5
6
7
Binary
0000
0001
0010
0011
0100
0101
0110
0111
Gray Code
0000
0001
0011
0010
0110
0111
0101
0100
Decimal
8
9
10
11
12
13
14
15
Binary
1000
1001
1010
1011
1100
1101
1110
1111
Gray code
1100
1101
1111
1110
1010
1011
1001
1000
33
Excess-3 code
Gray code
0011
0000
0100
0001
0101
0011
0110
0010
0111
0110
1000
0111
1001
0101
1010
0100
1011
1100
1100
1101
10
11
12
1111
Not
defined
1110
1010
13
1011
14
1001
15
1000
34
WARNING: CONVERSION OR
CODING
Do
10
35
ASCII
American
Standard
Code
for
Information Interchange.
36
ASCII TABLE
37
ERROR DETECTION
should
be
detected,
so
that
re-
38
EVEN PARITY
Even
ODD PARITY
Similar
1s odd
Examples
1000001 with odd parity is
11000001
1000011 with odd parity is
01000011
40
Odd
parity:
The
Even
The
parity:
EXAMPLE (1)
Suppose you receive a binary bit word 0101 and
you know you are using an odd parity.
Is the binary word errored?
The answer is yes:
PARITY BIT
makes
Example:
even parity
1000000(1)
1111101(0)
1001001(1)
Example:
odd parity
1000000(0)
1111101(1)
1001001(0)
PARITY CHECKING
Assume we are using even parity with 7-bit ASCII.
The letter V in 7-bit ASCII is encoded as 0110101.
How will the letter V be transmitted?
Because there are four 1s (an even number), parity is set to zero.
This would be transmitted as: 01101010.
EXERCISE 1
Suppose you are using an odd parity. What
should the binary word 1010 look like after you
add the parity bit?
Answer:
There
EXERCISE 2
Suppose you are using an even parity. What
should the binary word 1010 look like after you
add a parity bit?
Answer:
There