DLD Chapter - 2
DLD Chapter - 2
0111
00111 7
10101 21
11100 = 28
2.3 Binary Subtraction
0 0 1 1 0 1 0 1
2’s Complement
0 0 1 1 0 1 0 1
Input bits
Carry
Adder
in (add 1)
Output bits (sum)
0 0 1 1 0 1 1 0
2.4 Signed Binary Numbers
Examples:
00011110 = +30 00001110 = +14 11111111 = -1
00001111 = +15 11101111 = -17 11111000 = -8
00101101 = +45 11111101 = -3 1 11110111 = -9
Discard carry
continued…
8 8 1000
9 9 1001
Express 1A2F16 in decimal. 10 A 1010
11 B 1011
Start by writing the column weights:
12 C 1100
4096 256 16 1
13 D 1101
1 A 2 F16
14 E 1110
1(4096) + 10(256) +2(16) +15(1) = 670310 15 F 1111
4. Octal Numbers
Decimal Octal Binary
▪ Octal uses eight characters the
0 0 0000
numbers 0 through 7 to represent 1 1 0001
numbers. There is no 8 or 9 2 2 0010
character in octal. 3 3 0011
4 4 0100
▪ Binary number can easily be 5 5 0101
converted to octal by grouping bits 3 6 6 0110
at a time and writing the equivalent 7 7 0111
8 10 1000
octal character for each group.
9 11 1001
10 12 1010
Express 1 001 011 000 001 1102 in
11 13 1011
octal:
12 14 1100
Group the binary number by 3-bits 13 15 1101
starting from the right. Thus, 1130168 14 16 1110
15 17 1111
continued…
Decimal Octal Binary
▪ Octal is also a weighted number 0 0 0000
system. 1 1 0001
2 2 0010
▪ The column weights are powers of 3 3 0011
8, which increase from right to left. 4 4 0100
5 5 0101
6 6 0110
7 7 0111
Column weights {5128
3 82
64
81
8
80 .
1 . 8 10 1000
9 11 1001
Express 37028 in decimal. 10 12 1010
11 13 1011
Start by writing the column weights:
12 14 1100
512 64 8 1
13 15 1101
3 7 0 28
14 16 1110
3(512) + 7(64) +0(8) +2(1) = 198610 15 17 1111
5. BCD
Decimal Binary BCD
▪ Binary coded decimal (BCD) is 0 0000 0000
a weighted code that is 1 0001 0001
commonly used in digital 2 0010 0010
3 0011 0011
systems when it is necessary to
4 0100 0100
show decimal numbers such as 5 0101 0101
in clock displays. 6 0110 0110
7 0111 0111
• The table illustrates the difference 8 1000 1000
between straight binary and BCD. 9 1001 1001
BCD represents each decimal digit 10 1010 0001 0000
with a 4-bit code. 11 1011 0001 0001
12 1100 0001 0010
• Notice that the codes 1010 through
13 1101 0001 0011
1111 are not used in BCD.
14 1110 0001 0100
15 1111 0001 0101
6. Gray code
Decimal Binary Gray code