Lec 03
Lec 03
Lecture 03
Recap
Number System Conversion
Sum-of-Weights for converting to decimal
Binary Arithmetic
Similar to Decimal Arithmetic
Representing Numbers
Unsigned
Signed Magnitude
2’s Complement
2’s Complement form
0101 +5 0101 +5
0010 +2 1110 -2
0111 +7 10011 +3
1011 -5 1011 -5
1110 -2 0010 +2
11001 -7 1101 -3
Addition and Subtraction
2’s complement vs. Signed
2’s Complement Signed Binary
0101 +5 0101 +5
0010 +2 0010 +2
0111 +7 0111 +7
1011 -5 1101 -5
1110 -2 1010 -2
11001 -7 10111 -7
Addition and Subtraction
2’complement vs. Signed
0101 +5 0101 +5
1110 -2 1010 -2
10011 +3 1111 +3
1011 -5 1101 -5
0010 +2 0010 +2
1101 -3 1111 -3
Hexadecimal Number System
Base 16
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Representing Binary in compact form
1101100000110 = 1B06 H
2
Counting in Hexadecimal
Decimal Binary Hexadecimal Decimal Binary Hexadecimal
0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 10 1010 A
3 0011 3 11 1011 B
4 0100 4 12 1100 C
5 0101 5 13 1101 D
6 0110 6 14 1110 E
7 0111 7 15 1111 F
Counting in Hexadecimal
D 6 B 9 6
Hexadecimal to Binary Conversion
FD13
1111 1101 0001 0011
Decimal to Hexadecimal Conversion
Decimal to Hexadecimal Conversion
Indirect Method
Decimal →Binary → Hexadecimal
Repeated Division by 16
Repeated Division by 16
2096 131 0
131 8 3
8 0 8
Hexadecimal to Decimal Conversion
Hexadecimal to Decimal Conversion
Indirect Method
Hexadecimal →Binary → Decimal
Sum-of-Weights
Sum-of-Weights
CA02
(C x 163) + (A x 162) + (0 x 161) + (2 x 160)
(12 x 163) + (10 x 162) + (0 x 161) + (2 x 160)
(12 x 4096) + (10 x 256) + (0 x 16) + (2 x 1)
49152 + 2560 + 0 + 2
51714
Hexadecimal Addition & Subtraction
Hexadecimal Addition
Carry generated
Hexadecimal Subtraction
Borrow weight 16
Hexadecimal Addition
Carry 1
2AC6 6+5=11d Bh
+ 92B5 C+B=23d 17h
BD7B A+2+1=13d Dh
2+9=11d Bh
Hexadecimal Subtraction
Borrow 111
92B5 21-6=15d Fh
- 2AC6 26-C=14d Eh
67EF 17-A=7d 7h
8-2=6d 6h
Octal Number System
Base 8
0, 1, 2, 3, 4, 5, 6, 7
Representing Binary in compact form
1101100000110 = 15406
2 8
Counting in Octal
3 2 6 5 6 2 6
Octal to Binary Conversion
1726
001 111 010 110
Decimal to Octal Conversion
Decimal to Octal Conversion
Indirect Method
Decimal →Binary → Octal
Repeated Division by 8
Octal to Decimal Conversion
Octal to Decimal Conversion
Indirect Method
Octal →Binary → Decimal
Sum-of-Weights
Octal Addition & Subtraction
Octal Addition
Carry generated
Octal Subtraction
Borrow weight 8
Repeated Division by 8
4033
(4 x 83) + (0 x 82) + (3 x 81) + (3 x 80)
(4 x 512) + (0 x 64) + (3 x 8) + (3 x 1)
2048 + 0 + 24 + 3
2075
Octal Addition
Carry 1
7602 2+1=3d 3O
+ 5771 0+7=7d 7O
15573 6+7=13d 15O
1+7+5=13d 15O
Octal Subtraction
Borrow 11
7602 2-1=1d 1O
- 5771 8-7=1d 1O
1611 13-7=6d 6O
6-5=1d 1O
Alternate Representations
Binary Coded Decimal (BCD) code is used
to represent decimal digits in binary.
BCD code is a 4-bit binary code; the first
10 combinations represent the decimal
digits 0 to 9.
remaining six 4-bit combinations 1010,
1011, 1100, 1101, 1110 and 1111 are
considered to be invalid and do not exist.
BCD Addition
Gray Code
Alternate Representations
BCD (Binary Coded Decimal) Code representing the
decimal.
23 0010 0011
48 0100 1000
71 0110 1011
1011 is illegal BCD number
BCD Addition
Add a 0110 (6) to an invalid BCD number
Carry added to the most significant BCD digit
23 0010 0011
48 0100 1000
71 0110 1011
0110
0111 0001
Gray Code
The Gray code does not have any weights
assigned to its bit positions. The Gray Code is
not a positional code.
In BCD Code, there is more than 1 bit change
while in Gray code successive values of Gray
code differ by only one bit.
Electromechanical applications of digital
systems restrict bit change to 1.
Shaft encoders
Braking Systems
Un-Weighted Code
Gray Code
Gray Code representation of Decimal
values
Decimal Gray Binary
0 0000 0000
1 0001 0001
2 0011 0010
3 0010 0011
4 0110 0100
5 0111 0101
6 0101 0110
7 0100 0111
Alphanumeric Code
Numbers, Characters, Symbols
ASCII 7-bit Code
American Standard Code for Information
Interchange
10 Numbers (0-9)
26 Lower Case Characters (a-z)
26 Upper Case Characters (A-Z)
Punctuation and Symbols
32 Control Characters
ASCII Code
Odd Parity
Odd Parity Error
Detection
Original data 10011010
With Odd Parity 110011010
1-bit error 110111010
Number of 1s even indicates 1-bit error
2-bit error 110110010
Number of 1s odd no error indicated
3-bit error 100110010
Number of 1s even indicates error