EC203 Digital System Design
Module-1 Part-1
(Number System)
ECE Dept. BIT Mesra
Binary to Decimal Conversion
To convert a base 2 (binary) number to base 10 (decimal):
Add all the values (positional weights) where a one digit occurs
Positions where a zero digit occurs do NOT add to the value, and
can be ignored
Example 1: Convert binary 100101 to decimal
(written 1 0 0 1 0 1 )2 =
1*20 + 1+
0*21 +
1*22 + 4+
0*23 +
0*24 +
1*25 32
3710
Binary to Decimal Conversion
Example 1 Convert binary 101112 to decimal
positional powers of 2: 24 23 22 21 20
decimal positional value: 16 8 4 2 1
Ans 101112 = 2310
binary number:
1 0 1 1 1
16 + 4 + 2 + 1 = 2310
Example 2 Convert binary 100112 to decimal
positional powers of 2: 2 4 23 22 21 20
decimal positional value: 16 8 4 2 1 Ans 100112 = 1910
binary number:
1 0 0 1 1
16 + +2 +1 =1910
Example 3: Convert binary 1100102 to decimal
positional powers of 2: 25 24 23 22 21 20
decimal positional value: 32 16 8 4 2 1
Ans 1100102 = 5010
binary number: 1 1 0 0 1 0
32+ 16 + 2 = 5010
1(b) Decimal to Binary Conversion
(i) Division Method
Decimal to Binary Conversion
The Division Method:
1) Start with your number (call it N) in base 10
2) Divide N by 2 and record the remainder
3) If (quotient = 0) then stop
else make the quotient your new N, and go back to step 2
The remainders comprise your answer, starting with the last remainder as your first
(leftmost) digit.
In other words, divide the decimal number by 2 until you reach zero, and then
collect the remainders in reverse.
Converting a decimal number to a number in base r
Ques. Convert decimal 41 to binary.
Solution:
First, 41 is divided by 2 to give an integer quotient of 20 and a remainder of 12
Then the quotient is again divided by 2 to give a new quotient and remainder.
The process is continued until the integer quotient becomes 0.
The coefficients of the desired binary number are obtained from the remainders
as follows:
Decimal to Binary Conversion
Example 2: Convert decimal 2210 to binary
Using the Division Method
2210 =
2 ) 22 Rem
2 ) 11 0
2) 5 1
Ans 2210 = 101102
2) 2 1
2) 1 0
01
Example 3: Convert decimal 5610 to binary
Using the Division Method
5610 =
2 ) 56 Rem:
2 ) 28 0
Ans. 5610 = 1110002
2 ) 14 0
2) 7 0
2) 3 1
2) 1 1
0 1
1(b) Decimal to Binary Conversion
(ii) Subtraction Method
Decimal to Binary Conversion
The Subtraction Method:
Subtract out largest power of 2 possible (without going below zero),
repeating until you reach 0.
Place a 1 in each position where you COULD subtract the value
Place a 0 in each position that you could NOT subtract out the value
without going below zero.
Example 1: Convert decimal 2110 to binary
Using the Subtraction Method
2110= 26 25 24 23 22 21 20
21 64 32 16 8 4 2 1
- 16 1 0 1 0 1Ans. : 2110 = 101012
5
- 4 1
- 1
1 1
Decimal to Binary Conversion
Example 2: Convert decimal 5610 to binary
Using the Subtraction Method
5610= 26 25 24 23 22 21 20
56 64 32 16 8 4 2 1
- 32 1 1 1 0 0 0
24
Ans. : 5610 = 111002
- 16 1
8
- 8 1
0
Example 3: Convert decimal 4210 to binary
Using the Subtraction Method
4210= 26 25 24 23 22 21 20
42 64 32 16 8 4 2 1
- 32 1 0 1 0 1
10
Ans. : 5610 = 1010002
- 8 1
2
- 2 1
0
Octal Number System
Base: 8
Digits: 0, 1, 2, 3, 4, 5, 6, 7
Octal number: 3578 = (3 x 82 ) + (5 x 81) + (7 x 80)
To convert to base 10, beginning with the rightmost digit, multiply each nth digit
by 8(n-1), and add all of the results together.
Example1: Convert octal 3578 to decimal
Positional powers of 8: 8 2 81 80
Decimal positional value: 64 8 1
Octal number: 3 5 7
Value of 357 = (3 x 64) + (5 x 8) + (7 x 1)
= 192 + 40 + 7 = 23910
Answer: 3578 = 23910
Octal to Decimal Conversion
Example 2: Convert octal 12468 to decimal
Positional powers of 8: 8 3 82 81 80
Decimal positional value: 512 64 8 1
Octal number: 1 2 4 6
Value of 12468 (1 x 512) + (2 x 64) + (4 x 8) + (6 x 1)
= 512 + 128 + 32 + 6 = 67810
Answer: 12468 = 67810
Example 3: Convert octal 15038 to decimal
Positional powers of 8: 8 3 82 81 80
Decimal positional value: 512 64 8 1
Octal number: 1 2 4 6
Value of 12468 (1 x 512) + (5 x 64) + (0 x 8) + (3 x 1)
= 512 + 320 + 0 + 3 = 83510
Answer: 15038 = 83510
2(b) Decimal to Octal Conversion
(i) Division Method
Decimal to Octal Conversion
The Division Method:
1) Start with your number (call it N) in base 10
2) Divide N by 8 and record the remainder
3) If (quotient = 0) then stop
else make the quotient your new N, and go back to step 2
The remainders comprise your answer, starting with the last remainder as your first
(leftmost) digit.
In other words, divide the decimal number by 8 until you reach zero, and then collect
the remainders in reverse.
Example 1: Convert decimal 21410 to octal
Using the Division Method
21410 =
8 ) 214 Rem.
8 ) 26 6 Answer: 21410 = 3268
8) 3 2
0 3
Decimal to Octal Conversion
Example 2: Convert decimal 433010 to octal
Using the Division Method
433010=
8 ) 4330 Rem:
8 ) 541 2
8 ) 67 5 Answer: 433010 = 103528
8) 8 3
8) 1 0
0 1
Example 3: Convert decimal 433010 to octal
Using the Division Method
258110=
8 ) 2581 Rem:
8 ) 322 5 Answer: 258110 = 50258
8 ) 40 2
8) 5 0
0 5
2(b) Decimal to Octal Conversion
(ii) Subtraction Method
Decimal to Octal Conversion
The Subtraction Method:
Subtract out multiples of the largest power of 8 possible (without going
below zero) each time until you reach 0.
Place the multiple value in each position where you COULD subtract
the value.
Place a 0 in each position that you could NOT subtract out the value
without going below zero.
Example 1: Convert decimal 31510 to octal
315 82 81 80
- 256 (4 x 64) 64 8 1
59 4 7 3
- 56 (7 x 8)
3
- 3 (3 x 1) Answer: 31510 = 4738
0
Decimal to Octal Conversion
Example 2: Convert decimal 201810 to octal
Using Subtraction Method
2018 84 83 82 81 80
-1536 (3 x 512) 4096 512 64 8 1
482 3 7 4 2
- 448 (7 x 64)
34
- 32 (4 x 8)
2 Answer: 201810 = 37428
- 2 (2 x 1)
0
Example 3: Convert decimal 26910 to octal
Using Subtraction Method
269 82 81 80
- 192 (3 x 64) 64 8 1
77 3 9 5
- 72 ( 9 x 8)
5 Answer: 26910 = 3958
- 5 (3 x 1)
0
3(a) Hexadecimal to Decimal Conversion
Hexadecimal (Hex) Numbering System
Base: 16
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Hexadecimal (Hex) Extra Digits
Decimal Value Hexadecimal Digit
10 A
11 B
12 C
13 D
14 E
15 F
To convert to base 10,
beginning with the rightmost digit,
multiply each nth digit by 16(n-1), and
add all of the results together.
Hexadecimal number: 1F416 = (1 x 162 ) + (F x 161) + (4 x 160)
3(a) Hexadecimal to Decimal Conversion
Example 1: Convert Hexadecimal 1F416 to decimal
positional powers of 16: 163 162 161 160
decimal positional value: 4096 256 16 1
Hexadecimal number : 1 F 4
Value of 1F416 : (1 x 256) + (F x 16) + (4 x 1)
= (1 x 256) + (15 x 16) + (4 x 1)
= 256 + 240 + 4 = 50010
Answer: 1F416 = 50010
Example 2: Convert Hexadecimal 25AC16 to decimal
positional powers of 16: 163 162 161 160
decimal positional value: 4096 256 16 1
Hexadecimal number: 2 5 A C
Value of 25AC16 (2 x 4096) + (5 x 256) + (A x 16) + (C x 1)
= (2 x 4096) + (5 x 256) + (10 x 16) + (12 x 1)
= 8192 + 1280 + 160 + 12 = 964410
Answer: 25AC16 = 964410
3(b) Decimal to Hex Conversion
(i) Division Method
Decimal to Hex Conversion
The Division Method:
1) Start with your number (call it N) in base 10
2) Divide N by 16 and record the remainder
3) If (quotient = 0) then stop
else make the quotient your new N, and go back to step 2
The remainders comprise your answer, starting with the last remainder as your first
(leftmost) digit.
In other words, divide the decimal number by 16 until you reach zero, and then collect
the remainders in reverse.
Example 1: Convert decimal 12610 to Hexadecimal Using The
Division Method:
12610 =
16) 126 Rem:
16) 7 14= E
0 7= 7 Answer: 12610 = 7E16
Decimal to Hex Conversion
Example 2: Convert decimal 60310 to Hexadecimal
Using The Division Method:
60310 =
16) 603 Rem:
16) 37 11=B
Ans. 60310 = 25B16
16) 2 5
0 2
Example 3: Convert decimal 60310 to Hexadecimal
Using The Division Method:
184410 =
16) 1844 Rem:
16) 115 4
16) 7 3
0 7
3(b) Decimal to Hex Conversion
(ii) Subtraction Method
Decimal to Hex Conversion
The Subtraction Method:
Subtract out multiples of the largest power of 16 possible (without going below
zero) each time until you reach 0.
Place the multiple value in each position where you COULD to subtract the
value.
Place a 0 in each position that you could NOT subtract out the value without
going below zero.
Example 1: Convert decimal 81010 to Hexadecimal
Using The Subtraction Method
81010=
810 162 161 160
- 768 (3 x 256) 256 16 1
42 3 2 10 (A)
- 32 (2 x 16)
10 Answer: 81010 = 32A16
- 10 (10 x 1)
0
Decimal to Hex Conversion
Example 2: Convert decimal 15610 to Hexadecimal
Using The Subtraction Method
156 =
156 162 161 160
- 144 (9 x 16) 256 16 1
12 9 C
- 12 (12 x 1)
Answer: 15610 = 9C16
0
Example 3: Convert decimal 15610 to Hexadecimal
Using The Subtraction Method
88 =
88 162 161 160
- 80 (5 x 16) 256 16 1
8 5 8
- 8 (8 x 1)
0 Answer: 8810 = 5816
4(a) Octal to Binary Conversion
Octal to Binary Conversion
The maximum value represented in 3 bit is: 23 – 1 = 7
So using 3 bits we can represent values from 0 to 7=8 Digits which are the digits of the Octal
numbering system.
Thus, three binary digits can be converted to one octal digit.
Three-bit Group Decimal Digit Octal Digit
000 0 0
001 1 1
010 2 2
011 3 3
100 4 4
101 5 5
110 6 6
111 7 7
Octal to Binary Conversion
Example 1: Convert octal 7428 to binary
Convert each octal digit to 3 bits:
7428 =
7 = 111
4 = 100
2 = 010
111 100 010
Ans. 7428 = 1111000102
Example 2: Convert octal 5368 to binary
Convert each octal digit to 3 bits:
5368 =
5 = 101
3 = 011
6 = 110
101 011 110
Ans. 7428 = 1010111102
4(b) Binary to Octal Conversion
Binary to Octal Conversion
Example 1: Convert 101001102 to octal
Starting at the right end, split into groups of 3:
010 100 110
110 = 6
100 = 4
010 = 2 (pad empty digits with 0)
101001102 = 2468
Example 2: Convert 1001001102 to octal
Starting at the right end, split into groups of 3:
100 100 110
100 = 4
100 = 4
110 = 6
101001102 = 4468
5(a) Binary to Hex Conversion
Binary to Hex Conversion
The maximum value represented in 4 bit is: 24 – 1 = 15
So using 4 bits we can represent values 0 to 15=16 Digits which are the digits
of the Hexadecimal numbering system.
Thus, four binary digits can be converted to one hexadecimal digit.
Four-bit Group Decimal Digit Hexadecimal Digit
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 B
1100 12 C
1101 13 D
1110 14 E
1111 15 F
Binary to Hex Conversion
Example 1 : Convert 1101001102 to hex
Starting at the right end, split into groups of 4:
1 1010 0110
0110 = 6
1010 = A
0001 = 1 (pad empty digits with 0)
Ans. 1101001102 = 1A616
Example 2 : Convert 11111001102 to hex
Starting at the right end, split into groups of 4:
11 1110 0110
0110 = 6
1110 = E
0011 = 3 (pad empty digits with 0)
Ans 11111001102 = 3E616
5(b) Hex to Binary Conversion
Hex to Binary Conversion
Example 1: : Convert 3D916 to binary
Convert each hex digit to 4 bits:
3 = 0011
D = 1101
9 = 1001
Ans. 0011 1101 1001
3D916 = 11110110012 (can remove leading zeros)
6. Hex to Octal & Octal to Hex Conversion
Hex to Octal Conversion
To convert between the Hex to Octal number system
Convert from given Hex number to binary first
Then re-group obtained binary number in group of 3 bits
pad starting empty digits with 0 if required
convert from binary to the Octal numbering system starting on the right
Octal to Hex Conversion
To convert between the Octal to Hex number system
Convert from given Octal number to binary first
Then re-group obtained binary number in group of 4 bits
pad starting empty digits with 0 if required
convert from binary to the Hex number system starting on the right
Hex to Octal Conversion
Example 1 : Convert E8A16 to octal
First convert the hex to binary:
(E 8 A )16
1110 1000 10102
111 010 001 010 and re-group by 3 bits
Then convert the binary to octal:
7 2 1 2 (starting on the right)
Ans E8A16 = 72128
Example 2 : Convert C7D16 to octal
First convert the hex to binary:
(C 7 D )16
1100 0111 11012
110 001 111 101 and re-group by 3 bits
Then convert the binary to octal:
6 1 7 5 (starting on the right)
Ans C7D16 = 61758
Octal to Hex Conversion
Example 1 : Convert 7528 to hex
First convert the octal to binary:
( 7 5 2)8
111 101 0102
re-group by 4 bits starting from the right
0001 1110 1010 Add leading zeros if required
Then convert the binary to hex:
1 E A
Ans. 7528 = 1EA16
Example 2 : Convert 4278 to hex
First convert the octal to binary:
(4 2 7 )8
100 010 1112
re-group by 4 bits starting from the right
0001 0001 0111 Add leading zeros if required
Then convert the binary to hex:
1 1 7
Ans. 4278 = 11716
Conversion Problem
Convert the following numbers:
10101111012 to Hex
82F16 to Binary
Answers
• 10101111012 10 1011 1101 = 2BD16
• 82F16 = 0100 0010 1111 100001011112
Fractional Numbers
Example
Ex-1
(1011.101)2 =(?)10
Ex-2
Conversion of Fractional Part
(N)10 (fractional)= (M)b (fractional)
Decimal to binary
• The procedure for converting this is to multiply (N)10 (fractional) by b.
• If the resulting product is less than 1, then the most significant (leftmost) digit of the
• fractional part is 0.
• If the resulting product is greater than 1, the most significant digit of the fractional part is
the integer part of the product.
• The next most significant digit is formed by multiplying the fractional part of this product
by b and taking the integer part.
• The remaining digits are formed by repeating this process.
• The process may or may not terminate.
In general,
• Consider the number of integer part of the resulting product
Conversion of Fractional Part
Decimal to binary/ octal
Decimal to binary/ octal
Note: octal is equivalent to binary 3-bit group number, hence…0.101011=0.53
Codes can be categorized as
• Weighted
• Non-weighted
• 8 4 2 1 (Binary Coded Decimal)
Weighted: • 24 2 1
• Decimal • 8 4 -2 -1
• Other
• Binary
• Octal
• Hexadecimal
Non-Weighted:
• Gray Code [consecutive number differs by one bit]
• Excess-3 code [8421 CODE+3]
• ASCII code
Gray code
• The reflected binary code or Gray code is an ordering of the binary numeral system such
that two successive values differ in only one bit (binary digit).
• Gray codes are very useful in the normal sequence of binary numbers generated by the
hardware that may cause an error or ambiguity during the transition from one number to
the next.
ASCII code
• ASCII, stands for American Standard Code for Information
Interchange
• It's a 7-bit character code where every single bit represents a unique
character.
• ASCII is the most common character encoding format for text data
in computers and on the internet.
• In standard ASCII-encoded data, there are unique values for 128
alphabetic, numeric or special additional characters and control codes.
Addition Subtraction
Binary Arithmetic:
• Addition
• Subtraction
• Multiplication
• Division
Multiplication