Lecture-2 Recitation DLD
Lecture-2 Recitation DLD
Lecture-2 Recitation DLD
Weightage:
Weightage:
1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 + 0 x 2-1 + 0 x 2-2
+ 0 x 2-3 + 1 x 2-4
= 16 + 8 + 2 + 1/16 = (26.0625)10
Examples
Octal Number:
Convert (27.301)8 into Decimal:
Base = 8, r = 2, p = 3
Weightage:
Weightage:
Answer = (110101.01)2
Examples
Decimal to octal conversion:
Convert (53.25)10 into Octal.
First take whole number Then take the fractional
part: part:
Answer = (64.2)8
Examples
Decimal to hexadecimal conversion:
Convert (53.25)10 into Hexadecimal.
First take whole number Then take the fractional
part: part:
Answer = (45.4)16
Examples
Hexadecimal to binary conversion:
(AF0.2B)16 → (?)2
1. Convert (AF0.2B)16 into decimal using
weighted conversion.
2. Convert the result into binary using
successive division/ multiplication by 2.
Examples
Dec Hex Bin
Hexadecimal to binary 0
1
0
1
0000
0001
conversion: 2 2 0010
3 3 0011
(AF0.2B)16 → (?)2 4
5
4
5
0100
0101
6 6 0110
7 7 0111
8 8 1000
(1010) (1111) (0000) . (0010) (1011) 9 9 1001
10 A 1010
= (1010 1111 0000 . 0010 1011) 2 11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Examples
Dec Hex Bin
Binary to hexadecimal 0
1
0
1
0000
0001
conversion: 2 2 0010
3 3 0011
=(1B8.54)16 10
11
A
B
1010
1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Examples
Dec Hex Bin
Binary to octal 0
1
0
1
0000
0001
conversion: 2
3
2
3
0010
0011
4 4 0100
(1110111 . 010101) 2→ (?)8 5 5 0101
6 6 0110
7 7 0111
( 00 1) (110) (111) . (010) (101) 8 8 1000
9 9 1001
=(167.25)8 10
11
A
B
1010
1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Arithmatic Operations
Dec Hex Bin
• Addition 0 0 0000
1 1 0001
2 2 0010
AF.78C 3 3 0011
+ FEF.34 4 4 0100
5 5 0101
-------- 6 6 0110
7 7 0111
• Subtraction 8 8 1000
9 9 1001
10 A 1010
B3F.7C 11 B 1011
12 C 1100
- 18F.34
13 D 1101
-------- 14 E 1110
15 F 1111
Arithmatic Operations
Dec Hex Bin
• Multiplication 0
1
0
1
0000
0001
2 2 0010
3 3 0011
1 2 4 4 0100
5 5 0101
x 3 F
6 6 0110
-------- 7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Arithmatic Operations
Dec Hex Bin
• Division 0
1
0
1
0000
0001
____ 2 2 0010
3 3 0011
3 ) DEAD ( 4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 8 1000
9 9 1001
10 A 1010
11 B 1011
12 C 1100
13 D 1101
14 E 1110
15 F 1111
Arithmatic Operations
Dec Hex Bin
• Subtraction 0 0 0000
1 1 0001
2 2 0010
3 3 0011
B3F 4 4 0100
5 5 0101
- 18F 6 6 0110
----- 7 7 0111
8 8 1000
9 9 1001
10 A 1010
18F 11 B 1011
12 C 1100
- B3F 13 D 1101
----- 14 E 1110
15 F 1111
Radix and Diminished Radix Complement
String = N;
Base = n
Number of digits = r
n=2 3 3 0011
r=7 4 4 0100
5 5 0101
2’s complement of 1100110:
6 6 0110
(27-1)- 1100110 + 1 = 1111111 – 1100110 + 1 = 0011010 7 7 0111
Easier way to calculate: Flip all bits and add 1 to
result. 8 8 1000
9 9 1001
1011010
+ 0011010 10 A 1010
---------- 11 B 1011
0)1110100 Result = 1110100
12 C 1100
• AND operation:
Output is logic ‘1’ if all inputs are ‘1’. Even if a
single input is ‘0’, the output is ‘0’.
INPUT OUTPUT
A B Q = A AND B
0 0 0
0 1 0
1 0 0
1 1 1
(Bitwise) Logic Operations (Binary number system only)
• OR operation:
Output is logic ‘1’ if any of the inputs is ‘1’.
The output is ‘0’ if all inputs are ‘0’
INPUT OUTPUT
A B Q = A OR B
0 0 0
0 1 1
1 0 1
1 1 1
(Bitwise) Logic Operations (Binary number system only)
• OR operation:
Unary operator; Output is logic ‘1’ if input is
‘0’, and vice versa.
INPUT OUTPUT
A Q = NOT(A)
0 1
1 0