Digital concept
and
Number system
Chapter 1
Binary Codes
Shall I compare thee to
a summer’s day?
group of four binary digits represent
a single decimal digit0
1
2
3
4
5
6
7
8
9
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
Decimal BCD
Natural Binary Coded Decimal (BCD)
0
1
2
3
4
5
6
7
8
9
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
Decimal 8421 2421 Ex-3
0000
0001
0010
0011
0100
1011
1100
1101
1110
1111
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
Assign fixed
weight for
each bit
position
Weighted Binary Coded Decimal
Logic complements
– A logic complement of a binary digit is its
opposite value.
– The logic complement of 0 is 1 and the logic
complement of 1 is 0.
Ex,logic complement of (0011)2 is 1100.
BCD Self-complementing codes
*b is the radix of the numeral x
Two arithmetic complements
– Radix complement of x is written x’
– X’ = (b) – X
– diminish radix complement of x is written x-1’
– X-1’ = (b - 1) – X
10s complement (radix complement) of 610
10-6=410
9s complement ( Diminish radix complement ) of 610
10-1-6=310
1 0,0 1
BCD Self-complementing codes
BCD self-complement are designed so the
arithmetic diminished complement can be
found by taking the logical complement,a bit-
by-bit inversion of BCD code
Self-complementing code is a code whose
arithmetic and logic complement are the same.
0
1
2
3
4
5
6
7
8
9
Decimal 2421 Ex-3
0000
0001
0010
0011
0100
1011
1100
1101
1110
1111
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
BCD Self-complementing codes
Diminish radix complement
X=610
X-1’ = 10-1-6=310
6ex-3 = 1001
Logic complement of 6ex-3 is 0110.
3ex-3 = 0110
Only one bit change
occurs between successive
value in this code
Gray code
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Decimal binary Gray
0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
1111
1110
1010
1011
1001
1000
B =Bn-1Bn-2…Bi+1Bi…B1B0
G =Gn-1Gn-2…Gi+1Gi…G1G0
Bn-1=Gn-1 ; Gi=Bi+1⊕ Bi
Gn-1= Bn-1; Bi=Gi⊕ Bi+1
Unit Distance Code
Alphanumeric code
Alphabet /Punctuation
7-bit/8-bit ASCII code
– American standard code for information
interchange (ASCII)
Use the most significant bit position to indicate
sign
A,0” sign bit indicate a positive number,and a
“1” sign bit indicate a negative number
The remainder lesser significant bits to
represent magnitude.
Signed magnitude code &Complement code
Signed Number Binary Codes
2s(binary radix) complement codes
1s(diminished radix) complement codes
The complement code value for positive number is
equivalent to straight binary numbers with a,0” sign
bit added in the most significant position.
+bn-1bn-2…bi+1bi…b1b0 = 0bn-1bn-2…bi+1bi…b1b0
Complement Code
The 1s complement code for all negative numbers can
be found by first complementing each bit,then adding a
“1” in the sign bit position.
-bn-1bn-2…bi+1bi…b1b0 = 1bn-1’bn-2’…bi+1’bi’…b1’b0’
Negative 2s complement codes are found by first
finding the 1s complement and then adding 1 to the
result.
Complement Code
2s(binary radix) vs 1s(diminished radix) complement codes
Identical for positive value
ex,(1101)2=(01101)2S=(01101)1S
The 2s complement code is only one value for 0 whereas 1s
complement code has two
ex,(0000)2=(00000)2s=(00000)1s ; (-0000)2=(00000)2s=(11111)1s
The 2s complement code for negative value is the same as
1s complement code plus 1
ex,(-13)10=(-1101)2 =(10010)1S =(10011)2S
Complement Code
Complement vs complement code
Find the 2s and 1s complement of (110011)2
– (110011)’ =26 - 110011=001101
– (110011)-1’ =26 – 110011-1=001100
Find the 2s and 1s complement code of (+110011)2
– (+110011)2S = (+110011)1S =0110011
Find the 2s and 1s complement code of (-110011)2
– (-110011)2S=1001101
– (-110011)1S=1001100
Complement vs complement code
Find the 2s complement and 1s complement of
(1100.11)2
– (1100.11)’ =24 – 1100.11=0011.01
– (1100.11)-1’ =0011.00
– The 1s (radix diminish) complement of binary
number N is its opposite value.
Complement vs complement code
Find the 5s complement and 4s complement of
(321.4)5
– (321.4)’ =53 –=.123.1
– (321.4)-1’ = 53- 321.4-0.1=444.4-321.4=123.0
and
Number system
Chapter 1
Binary Codes
Shall I compare thee to
a summer’s day?
group of four binary digits represent
a single decimal digit0
1
2
3
4
5
6
7
8
9
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
Decimal BCD
Natural Binary Coded Decimal (BCD)
0
1
2
3
4
5
6
7
8
9
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
Decimal 8421 2421 Ex-3
0000
0001
0010
0011
0100
1011
1100
1101
1110
1111
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
Assign fixed
weight for
each bit
position
Weighted Binary Coded Decimal
Logic complements
– A logic complement of a binary digit is its
opposite value.
– The logic complement of 0 is 1 and the logic
complement of 1 is 0.
Ex,logic complement of (0011)2 is 1100.
BCD Self-complementing codes
*b is the radix of the numeral x
Two arithmetic complements
– Radix complement of x is written x’
– X’ = (b) – X
– diminish radix complement of x is written x-1’
– X-1’ = (b - 1) – X
10s complement (radix complement) of 610
10-6=410
9s complement ( Diminish radix complement ) of 610
10-1-6=310
1 0,0 1
BCD Self-complementing codes
BCD self-complement are designed so the
arithmetic diminished complement can be
found by taking the logical complement,a bit-
by-bit inversion of BCD code
Self-complementing code is a code whose
arithmetic and logic complement are the same.
0
1
2
3
4
5
6
7
8
9
Decimal 2421 Ex-3
0000
0001
0010
0011
0100
1011
1100
1101
1110
1111
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
BCD Self-complementing codes
Diminish radix complement
X=610
X-1’ = 10-1-6=310
6ex-3 = 1001
Logic complement of 6ex-3 is 0110.
3ex-3 = 0110
Only one bit change
occurs between successive
value in this code
Gray code
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Decimal binary Gray
0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
1111
1110
1010
1011
1001
1000
B =Bn-1Bn-2…Bi+1Bi…B1B0
G =Gn-1Gn-2…Gi+1Gi…G1G0
Bn-1=Gn-1 ; Gi=Bi+1⊕ Bi
Gn-1= Bn-1; Bi=Gi⊕ Bi+1
Unit Distance Code
Alphanumeric code
Alphabet /Punctuation
7-bit/8-bit ASCII code
– American standard code for information
interchange (ASCII)
Use the most significant bit position to indicate
sign
A,0” sign bit indicate a positive number,and a
“1” sign bit indicate a negative number
The remainder lesser significant bits to
represent magnitude.
Signed magnitude code &Complement code
Signed Number Binary Codes
2s(binary radix) complement codes
1s(diminished radix) complement codes
The complement code value for positive number is
equivalent to straight binary numbers with a,0” sign
bit added in the most significant position.
+bn-1bn-2…bi+1bi…b1b0 = 0bn-1bn-2…bi+1bi…b1b0
Complement Code
The 1s complement code for all negative numbers can
be found by first complementing each bit,then adding a
“1” in the sign bit position.
-bn-1bn-2…bi+1bi…b1b0 = 1bn-1’bn-2’…bi+1’bi’…b1’b0’
Negative 2s complement codes are found by first
finding the 1s complement and then adding 1 to the
result.
Complement Code
2s(binary radix) vs 1s(diminished radix) complement codes
Identical for positive value
ex,(1101)2=(01101)2S=(01101)1S
The 2s complement code is only one value for 0 whereas 1s
complement code has two
ex,(0000)2=(00000)2s=(00000)1s ; (-0000)2=(00000)2s=(11111)1s
The 2s complement code for negative value is the same as
1s complement code plus 1
ex,(-13)10=(-1101)2 =(10010)1S =(10011)2S
Complement Code
Complement vs complement code
Find the 2s and 1s complement of (110011)2
– (110011)’ =26 - 110011=001101
– (110011)-1’ =26 – 110011-1=001100
Find the 2s and 1s complement code of (+110011)2
– (+110011)2S = (+110011)1S =0110011
Find the 2s and 1s complement code of (-110011)2
– (-110011)2S=1001101
– (-110011)1S=1001100
Complement vs complement code
Find the 2s complement and 1s complement of
(1100.11)2
– (1100.11)’ =24 – 1100.11=0011.01
– (1100.11)-1’ =0011.00
– The 1s (radix diminish) complement of binary
number N is its opposite value.
Complement vs complement code
Find the 5s complement and 4s complement of
(321.4)5
– (321.4)’ =53 –=.123.1
– (321.4)-1’ = 53- 321.4-0.1=444.4-321.4=123.0