02 DLD
02 DLD
NU-BCS
Lecture 1
content
•Number System
•Conversions
•Binary Arithmetic
•Complements
Number System
• Method
1. Divide decimal number by 2
2. Repeat this method until quotient is less than 2
3. Bottom to top sequence of remainders will be the required
binary number
(14)10 to (?)2
• 14/2 0
• 7/2 1
• 3/2 1
• 1
(14)10 to (1110)2
Practice
1. (43)10 to (101011)2
2. (164)10 to (10100100)2
3. (333)10 to (101001101)2
4. (4096)10 to (1000000000000)2
Conversion of Decimal Fraction to a
Binary Fraction
• Method:
• Multiply decimal fraction by 2.
• Repeat this process with fraction until no fraction found.
• Decimal point placed in the same position in binary
number.
• Top to bottom sequence of whole number will be the
required binary number.
(0.25)10 to (?)2
1. 0.25×2= 0.5
2. 0.5×2= 1.0
• (0.25)10 to (0.01)2
Practice
1. (0.375)10 to (0.011)2
2. (0.4375)10 to (0.0111)2
3. (0.625)10 to (0.101)2
4. (27/32)10 to (0.11011)2
Conversion Decimal Fraction to Binary
Fraction contains Whole number
• Method
1. Convert whole number as described in case-a and store in
x.
2. Convert fraction as described in case-b and store in y.
3. The decimal point is placed in the same position in binary
number as is present in the decimal number.
4. Add the two result x+y. Resultant will be the converted
binary number.
(2.125)10 to (?)2
•. Case-b
Case-a Case-3
(0.125)10 to (?)2
(2)10=(x)2 Add the two result X and
y
X=10
0.125×2 Y=0.001
2/2 0 =0.25 X+Y=10+0.001
1 0.25×2
=0.5
0.5×2
X=10 =1.0 (2.125)10 to (10.001)2
Y=0.001
Practice
1. (2 3
/8 )10 =(10.011)2
2. (512.5)10 =(1000000000.1)2
3. (131.5625 )10 =(10000011.1001)2
4. (2048.0625)10 =(100000000000.0001)2
2.Decimal Number System Octal Number
System
• Method
1. Divide Decimal Number by 8.
2. Repeat this method until quotient is less than 8.
3. Bottom to top sequence of reminders will be required
octal number.
(19)10 to (?)8
• 19/8 3
• 2
• X=23
• (19)10 to (23)8
Practice
1. (125)10 to (175)8
2. (332)10 to (514)8
3. (2473)10 to (4651)8
4. (11570)10 to (26462)8
Conversion of decimal fraction to an
Octal Fraction
• Method
1. Multiply decimal fraction by 8
2. Repeat this process with fraction only until no fraction is
found .
3. The decimal point placed in the same position in Octal
number as present in the decimal number system.
4. Top to bottom sequence of whole number will be the
required octal number.
(0.55)10 to (?)8
• 0.55×8 =4.4
• 0.4×8 =3.2
• 0.2×8 =1.6
• 0.6×8 =4.8
• 0.8×8 =6.4
(0.55)10 to (0.43146)8
Practice
1. (0.625)10 to (0.5)8
2. (0.771)10 to (0.61260)8
3. (0.1123)10 to (0.07137)8
4. (0.23561)10 to (0.17050)8
Conversion Decimal Fraction to Octal
Fraction contains Whole number
• Method
1. Convert whole number as described in case-a and store in
x.
2. Convert fraction as described in case-b and store in y.
3. The decimal point is placed in the same position in Octal
number as is present in the decimal number.
4. Add the two result x+y. Resultant will be the converted
Octal number.
(8.99)10 to (?)8
• Case-a Case-b
1. (2.125)10 to (2.1)8
2. (632.97)10 to (1170.76050)8
3. (113.20)10 to (161.14631)8
4. (4429.625)10 to (10515.5)8
Decimal Number System Hexadecimal Number
System
• Method:
• Divide Decimal number by 16
• Repeat this process until quotient is less than 16
• Bottom to top sequence of remainders will be the required
Hexadecimal number.
(40)10 to (?)16
• 40/16 8
• 2
• X=28
• (40)10 to (28)16
(397)10 to (?)16
1. (1343)10 to (53F)16
2. (5132)10 to (140c)16
3. (26295)10 to (66B7)16
Conversion of Decimal Fraction to a
Hexadecimal Fraction
• Method
1. Multiply decimal fraction by 16
2. Repeat this process with fraction only until no fraction is
found .
3. The decimal point placed in the same position in
Hexadecimal number as present in the decimal number
system.
4. Top to bottom sequence of whole number will be the
required Hexadecimal number.
(0.23)10 to (?)16
1. 0.23×16 =3.68
2. 0.68×16 =10.88 (A)
3. 0.88×16 =14.08 (E)
4. 0.08×16 =1.28
5. 0.28×16 =4.48
(0.23)10 to
(0.3AE14)16
Practice
1) (0.62)10 to (0.9EB85)16
2) (0.235)10 to (0.3C28F)16
3) (0.114)10 to (0.1D2F1)16
4) (0.0298)10 to (0.07A0F)16
Conversion Decimal Fraction to
Hexadecimal Fraction contains Whole
number
• Method
1. Convert whole number as described in case-a and store in
x.
2. Convert fraction as described in case-b and store in y.
3. The decimal point is placed in the same position in Octal
number as is present in the decimal number.
4. Add the two result x+y. Resultant will be the converted
Hexadecimal number.
(50.8)10 to (?)16
•.
• Case-a Case-b Case-3
• (99.99)10 to (63.FD70A)16
• (336.125)10 to (150.2)16
• (825.625)10 to (63.FD70A)16
• (1029.2213)10 to (405.38A71…)16
Conversion of Binary Decimal Number
• Method:
• Write binary number in power of 2(Base of binary System)
• Calculate the powers this will give the number in decimal.
(111001)2 to (?)10
2. (11011)2 to (?)10
• (11011)2= 1⋅24+1⋅23+0⋅22+1⋅21+1⋅20
• =16+8+0+2+1
• =27
• (11011)2 to (27)10
Practice
• (11000)2 to (24)10
• (100011)2 to (35)10
• (111001)2 to (57)10
• (1011010)2 to (90)10
Conversion of binary fraction to Decimal
Fraction
• Method
• Write binary number in power of +ve 2
• Write binary fraction in power of –ve 2
• Calculate the powers this will give the number in decimal.
(111.1011)2 to (?)10
• (1011.0011)2 to (11.1875)10
• (101.101011)2 to (5.671875)10
• (111011.1011)2 to (59.6875)10
• (10110.0101011101)2 to (22.34082031)10
Octal number System Decimal Number
System
• Method
• Write octal number in power of 8
• Calculate the powers this will give the number in decimal
(124)8 to (?)10
• (124)8 to (84)10
Practice
• (156)8 to (110)10
• (2376)8 to (1278)10
• (22632)8 to (9626)10
• (743126)8 to (247382)10
Conversion of Octal number to Decimal
containing fraction
• Method
• Write Octal number in power of +ve 8
• Write Octal fraction in power of –ve 8
• Calculate the powers this will give the number in decimal.
(0.52)8 to (?)10
• (0.52)2 = 0⋅80+5×8-1+2×8-2
•
• =0×1+5×0.125+2×0.015625
• =0+0.625+0.03125
• (0.52)8 to (0.56625)10
Practice
• (1.123)8 to (1.16210)10
• (0.5627)8 to (0.72436525)10
• (15.6)8 to (13.75)10
• (71.234)8 to (57.7265625)10
Hexadecimal Number Decimal Number
• Method
• Write Hexadecimal number in power of 16
• Calculate the powers this will give the number in decimal.
(15)16 to (?)10
• (AB4)16 to (2740)10
• (64AC)16 to (25772)10
• (EB1A)16 to (56090)10
• (D2763)16 to (862051)10
Conversion of Hexadecimal to Decimal
containing Fraction
• Method
• Write hexadecimal whole number in power of +ve 16
• Write hexadecimal fraction in power of –ve 16
• Calculate the powers this will give the number in Decimal.
(9.B)16 to (?)10
• (5.1A)16 to (5.102)10
• (BC.1A)16 to (188.10156)10
• (0.152B)16 to (0.082687368)10
• (Af.23C)16 to (175.13964)10
Binary Number System Octal Number
System
• Method
• Break binary number into groups of three bits each,
starting from the right most bit towards left.
• If the left most group contains less than three bits then add
zero(s) to the left , so that a group of three bits can be
formed. This additional zero is written as 0 in the following
example.
• Write Octal number against each group of three bits from
table.
(111001)2 to (?)8
(111001)2 to
(71)8
Practice
• (10110111)2 to (267)8
• (111000001010)2 to (7012)8
• (1011111000001)2 to (12701)8
• (100000000011111111)2 to (400377)8
Conversion of Binary Number to Octal
Number containing Fraction
• Method
• Break binary number into groups of three bits each starting
from right towards left in whole numbers and starting from
the left towards right in fraction.
• If the left most group in whole number and right most
group in fraction respectively contains less than three bits
then add Zero(s)
To the left in whole number or right in fraction.
• The point is placed in the same position in Octal Number as
is present in binary number.
(111.111)2 to (?)8
• 111.111
7.7
(111.111)2 to (7.7)8
Practice
• (1111.1101)2 to (17.64)8
• (0.101111010101)2 to (0.5725)8
• (110110.011)2 to (66.3)8
• (11.1011011)2 to (3.554)8
Octal Number System Binary Number
System
• Method
• Write a group of three bits against each octal digit from
table.
• If any group contains less than three bits then add zero (s)
to the left so that a group of three bits can be formed.
• Joins these binary digits and result will be the binary
equivalent of octal number.
(54)8 to (?)2
•5 4
101 100
(54)8 to (101100)2
Practice
• ( 652)8 to (110101010)2
• (1364)8 to (001011110100)2
• (7423)8 to (111100010011)2
• (53762)8 to (101011111110010)2
Conversion of Octal to Binary containing
Fraction
• Method
• Write a group of three bits against each octal digit from
table
• If any group contains less than three bits then add zero(s)
to the left so that a group of three bits can be formed this
zero is written as 0
• The point is placed int the same position in binary number
as is present in Octal number
• Join these binary digits and result will be the binary
equivalent of octal number
(232.2)8 to (?)2
2 3 2 . 2
(232.2)8 to
(010011010.010)2
Practice
• (453.45)8 to (?)2
• (3232.14)8 to (?)2
• (3146.52)8 to (?)2
• (0.03125)8 to (?)2
Binary Number System Hexadecimal
Number System
• Method
• Break binary number into groups of four bits each starting
room the right most bit towards left
• If the left most group contains less than four bits then add
zero(s) to the left so tat a group of four bits can be formed
• Write hexadecimal number against each group of four bits
from table
(10011100)2 to (?)16
• 1001 1100
9 C
(10011100)8 to
(9C)16
Practice
• (101101111010)2 to (?)16
• (1000111110101)2 to (?)16
• (110000111110010000)2 to (?)16
• (101000000011110101011010)2 to (?)16
Conversion of Binary number to
hexadecimal number containing fraction
• Method
• Break binary number into groups of four bits starting from
the right towards left in whole numbers and starting from the
left towards right in fraction
• If the left most group in whole number and right most group
in fraction respectively contains less than four bits then add
Zero(s) to the left in whole number or right in fraction so that
a group of four bits can be formed.
• The point is placed in the same position in hexadecimal
number as is present in binary mumber.
(1101.0110)2 to (?)16
• 1101 . 0110
D 6
(1101.0110)8 to
(D6)16
Practice
• (11110.01011)2 to (?)16
• (1011.11010)2 to (?)16
• (0.01111110)2 to (?)16
• (0.1100101001010111)2 to (?)16
Hexadecimal number System Binary
Number System
• Method
• Write a group of four bits against each hexadecimal digit
from table
• If any group contains less than four bits then add zero(s) to
the left so that a group of four bits can be formed
• Join these binary digits and result will be the binary
equivalent of hexadecimal number.
(AB)16 to (?)2
• A B
1010 1011
(AB)16 to (10101011)2
Practice
• (CDEF)16 to (?)2
• (6A9)16 to (?)2
• (23F0)16 to (?)2
• (415E7)16 to (?)2
Conversion of Hexadecimal to binary
containing Fraction
• Method
• Write a group of four bits against each hexadecimal digit
from table
• If any group contains less than four bits then add Zero(s) to
the left so that a group of four bits can be formed
• The point is placed in the same position in binary number
as is present in hexadecimal number
(AA.1A)16 to (?)2
• A A . 1 A
(AA.1A)16 to (10101010.00011010)2
Practice
• (ABC.CBA)16 to (?)2
• (AB2.234)16 to (?)2
• (0.CF83.1A)16 to (?)2
• (0.10A4EF)16 to (?)2
Octal Number System Hexadecimal
Nmber
• Method
• Conversion performed in two phases
1. Conversion of Octal number to Binary
2. Conversion of Binary number to hexadecimal number
(17)8 to (?)16
• Step 1 Step 2
• 1 7 Break binary
number into group
of Four bits
001 111 001111
(17)8 to (F)16
(17)8 to (001111)2
Practice
• (235)8 to (?)16
• (4126)8 to (?)16
• (70523)8 to (?)16
• (154420)8 to (?)16
Conversion of Octal Number To
Hexadecimal containing Fraction
• Method
• This conversion is performed in two phase
1. Conversion of Octal Number to Binary Number
2. Conversion of Binary Number to Hexadecimal Number
(1.5)8 to (?)16
Step 2
• Step 1
Break binary
• 1 . 5 number into group
of Four bits
0001.1010
001 101
(1.5)8 to
(1.A)16
(1.5)8 to (001.011)2
Practice
• (33.1)8 to (?)16
• (62.47)8 to (?)16
• (153.10)8 to (?)16
• (2031.07)8 to (?)16
Hexadecimal Number Octal Number
• Method
• This conversion is performed in two phases
1. Conversion of Hexadecimal number to Binary Number
2. Conversion of Binary number to Octal Number
(44)16 to (?)8
Step 2
• Step 1
Break binary
• 4 4 number into group
of three bits
001000100
0100 0100
(44)16 to
(104)8
(44)16 to (01000100)2
Practice
• (12F)16 to (?)8
• (30C5)16 to (?)8
• (ABD001)16 to (?)8
• (B4E60)16 to (?)8
Conversion of Hexadecimal to Octal
containing Fraction
• Method
• This conversion is performed in two phase
1. Conversion of Hexadecimal number to Binary number
2. Conversion of Binary number to Octal number
(2.3)16 to (?)8
Step 2
• Step 1
Break binary
• 2 . 3 number into group
of three bits
010.001100
0010 0011
(44)16 to
(2.14)8
(2.3)16 to (0010.0011)2
Practice
• (D5.7)16 to (?)8
• (64.EF)16 to (?)8
• (987.1B)16 to (?)8
• (9937.88)16 to (?)8
Binary Arithmetic
A. 100+111
B. 11101+101
C. 1100+1101
D. 101010+1111
Binary Subtraction
10 2-1=1
_ 1
_________
1
Example2
10 0 4-2=2
_ 1 0
_________
10
Example3
Example4
• 1101-1000
• 1101-1011
• 10111101-1011111
• 11111111-1111111
Binary Multiplication
• 11×11
• 1100×101
• 1111×1101
• 1111×1010
Binary Division
• 11001 ÷ 101=101
Practice
• 1000÷10
• 1111÷11
• 11001÷101
• 100100÷100
Complement Arithmetic
• 11111
• - 10101
• _______
• 01010 1’s complement
2's complement
• 110
• 1101
• 11111
• 10110
• 110111
Subtraction in 1’s Complement
A smaller number subtracted from a large number
• Method:
• Take the subtrahend and find out its 1’s complement.
• Now add this 1’s complement to the minuend.
• Add the carry to the right digit of the result.
Regular subtraction
111
101 1’s complement subtraction -11
-----------
_ 11 100 (1’s
comp)
_______
010 101
+ 100
________________
1 001 add
Carry
+ 1
___________________
010
1’s complement Carry is Produced
(111010) – (101011)
(111010) – (101011)
111010
+ 010100
___________
1001110
Drop the carry and add to the number
001110
+ 1
_________
001111
A larger number is to be subtracted from
smaller number
• Method:
• Take the subtrahend and find out its 1’s complement.
• Now add this 1’s complement to the minuend.
• No carry is generated show that the answer is negative.
Regular subtraction
11
10 1’s complement subtraction -11
-----------
_ 11 00 (1’s
_______ comp)
_ 01 10
+ 00
________________
10
___________________
Again complement and
assign negative sign
-01
No carry (100110)-(110001)
• (100110)-(110001)
• 100110
• + 001110
• _________
• 110100 (no carry again complement and assign negative)
• _ 001011
2’s complement
smaller number subtracted from larger number
• Method
• Take the subtrahend and find out its 1’s Complement.
• Add 1 to the right digit of the 1’s complement.
• Now take this total and ad it with the minuend.
• Left most 1 will be dropped down resultant will be the 2’s
complement.
Carry produced
• (1111)-(1001)
• 0110 1111
• + 1 + 0111
• _______ ____________
• 0111 2’s com 10110 ( drop the carry ) result =0110
A large number subtracted from smaller
number
• Method:
• Take the subtrahend and find out its 1’s complement.
• Now add this 1’s complement answer to the minuend.
• No carry is generated which shows that the answer is
negative and is complement of the regular subtraction.
No carry
• (1000) – (1101)