Professional Documents
Culture Documents
Digital Electronics: CT 304N Unit:1 Number Systems and Codes
Digital Electronics: CT 304N Unit:1 Number Systems and Codes
Unit:1
Number Systems and Codes
Used by Used in
System Base Symbols humans computers
? ?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa- 16 0, 1, … 9, No No
decimal A, B, … F
The Decimal Number System
• where point separates the whole part and the fractional part.
• By following the general rule any number system can be developed.
Common Number Systems
Used by Used in
System Base Symbols humans computers
? ?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa- 16 0, 1, … 9, No No
decimal A, B, … F
Digital Electronics??
• Importance of the subject
• Motivation for studying the subject
Digital Era
• Digital age and information age
• Digital computers
• General purposes
• Many scientific, industrial and commercial applications
• Digital systems
• Telephone switching exchanges
• Digital camera
• Electronic calculators, PDA's
• Digital TV
• Discrete information-processing systems
• Manipulate discrete elements of information
• For example, {1, 2, 3, …} and {A, B, C, …}…
Analog and Digital Signal
• Analog system
• The physical quantities or signals may vary continuously over a specified
range.
• Digital system
• The physical quantities or signals can assume only discrete values.
• Greater accuracy
X(t) X(t)
t t
Analog signal Digital signal
Binary Digital Signal
• An information variable represented by physical quantity.
• For digital systems, the variable takes on discrete values.
• Two level, or binary values are the most prevalent values.
• Binary values are represented abstractly by:
V(t)
• Digits 0 and 1
• Words (symbols) False (F) and True (T)
• Words (symbols) Low (L) and High (H) Logic 1
• And words On and Off
undefine
• Binary values are represented by values
or ranges of values of physical quantities. Logic 0
t
Binary digital signal
Digital Systems and Binary Numbers
• Computers happen to operate using the base-2 number system, also
known as the binary number system, just like the base-10 number
system is known as the decimal number system to human beings.
The fundamental point
• Modern computers use binary number system, in which there are
only zeros and ones. (Only two symbols)
• A “bit” to binary is similar a “digit” to a decimal information. (Again,
the easiest way to understand bits is to compare them to something
you know: digits.)
• A bit has a single binary value, either 0 or 1.
Binary vs. Decimal
• Binary is a base two system which works just like our decimal system.
• Considering the decimal number system, it has a set of values which
range from 0 to 9.
• The binary number system is base 2 and therefore requires only two
digits, 0 and 1.
The fundamental point
• Binary representation of numbers and other information is the
representation which can be understood by computer chips and can
be saved in memory.
• It is important to computers because all computer data is ultimately
represented by a series of zeros and ones, no matter you realize it or
not.
You might ask
• Why don’t computers use the base-10 decimal system for numbers,
counting and arithmetic?
• Why not 4 based, 7 based?
• Why 2 based?
• We know that the computer doesn't have a real brain inside. In fact, it
is made up mostly of semiconductor materials such as silicon. Yet, a
computer acts in many ways as if it does have a real brain, because it
can store (memorize) data and derive new information (operations)
from the input data.
Why binary?
• But from this on-off, yes-no 1-0 state, all things may can be
represented completely and calculated correctly.
Digital Systems and Binary Numbers
• As digital systems are more efficient than analog systems they are
more prevalent today i.e. digital computers, digital cameras etc.
• Binary logic is the simplest to implement in a digital system.
• So, digital systems with binary logic are used.
Logic 1
undefine
Logic 0
Decimal Number System
• Base (also called radix) = 10
• 10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
• Digit Position 2 1 0 -1 -2
(512.74)10
Octal Number System
• Base = 8
• 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
64 8 1 1/8 1/64
• Weights
5 1 2 7 4
• Weight = (Base) Position
2 1 0 -1 -2
• Magnitude
5 *82+1 *81+2 *80+7 *8-1+4 *8-2
• Sum of “Digit x Weight”
• Formal Notation =(330.9375)10
(512.74)8
Binary Number System
• Base = 2
• 2 digits { 0, 1 }, called binary digits or “bits”
• Weights
4 2 1 1/2 1/4
• Weight = (Base) Position
1 0 1 0 1
• Magnitude
• Sum of “Bit x Weight” 2 1 0 -1 -2
1 *22+0 *21+1 *20+0 *2-1+1 *2-2
• Formal Notation
• Groups of bits 4 bits = Nibble
=(5.25)10
11000101
Hexadecimal Number System
• Base = 16
• 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }
• Weights
Position 256 16 1 1/16 1/256
• Weight = (Base)
1 E 5 7 A
• Magnitude
• Sum of “Digit x Weight” 2 1 0 -1 -2
1 *162+14 *161+5 *160+7 *16-1+10 *16-2
• Formal Notation
=(485.4765625)10
(1E5.7A)16
Common Number Systems
Used by Used in
System Base Symbols humans computers
? ?
Decimal 10 0, 1, … 9 Yes No
Binary 2 0, 1 No Yes
Octal 8 0, 1, … 7 No No
Hexa- 16 0, 1, … 9, No No
decimal A, B, … F
Conversion Among Bases
• The possibilities:
Decimal Octal
Binary Hexadecimal
Conversions:
1. Decimal to Binary 7. Binary to octal
2. Binary to decimal 8. Binary to hexadecimal
3. Decimal to octal 9. Octal to hexadecimal
4. Octal to decimal 10. Octal to binary
5. Decimal to hexadecimal 11. Hexadecimal to octal
6. Hexadecimal to decimal 12. Hexadecimal to binary
1. Decimal to Binary Conversion
Decimal Octal
Binary Hexadecimal
Decimal to Binary Conversion
2 31 0
15 1
2
7 1
2
2 3 1
2 1 1
0 1
12510 = 11111012
Convert decimal fraction 0.78125 to binary
0.78125*2 = 1.5625 carry 1
0.5625 *2 = 1.125 carry 1
0.125 *2 = 0.25 carry 0
0.25 *2 = 0.5 carry 0
0.5 *2 = 1.0 carry 1
(0.6)10 = (0.10011........)2
Practice: 1
• Find the binary equivalent of decimal 35
• Solution: 2 17 1 ↑
2 8 1 ↑
(35)10 = (_______)2 2 4 0 ↑
2 2 0 ↑
2 1 0 ↑
0 1 ↑
• ∴ (35)10 = (100011)2
Practice: 2
• Find the binary equivalent of decimal 0.35
• ∴ (0.35)10 = (0.010110)2
Combining 1 and 2
• Find the binary equivalent of decimal 35.35 is
• 100011.010110
2 35 0.35 × 2 = 0.70 0 ↓
2 17 1 ↑ 0.70 × 2 = 1.40 1 ↓
2 8 1 ↑ 0.40 × 2 = 0.80 0 ↓
2 4 0 ↑ 0.80 × 2 = 1.60 1 ↓
2 0 ↑
2
0.60 × 2 = 1.20 1 ↓
2 1 0 ↑
0.20 × 2 = 0.40 0 ↓
0 1 ↑
More examples:
• Find binary equivalent of following decimal numbers:
(i) 29
(ii) 47
(iii) 0.692
(iv) 0.8125
(v) 25.188
Answers:
• Find binary equivalent of:
(i) 29 = 11101
(ii) 47 = 101111
(iii) 0.692 = 0.1011
(iv) 0.8125 = 0.1101
(v) 25.188 = 11001.00110
Answers:
2 29
(29)10 = ( ? )2
2 14 1 ↑
Solution: 2 7 0 ↑
(29)10 = (_______)2
2 3 1 ↑
∴ (29)10 = (11101)2 2 1 1 ↑
0 1 ↑
Answers:
(47)10 = ( ? )2 2 47
2 23 1 ↑
Solution: 2 11 1 ↑
(47)10 = (_______)2
2 5 1 ↑
2 2 1 ↑
∴ (47)10 = (101111)2 2 1 0 ↑
0 1 ↑
Answer:
• (0.692)10 = ( ? )2
• Solution: (0.692)10 = (_______)2
• (0.692)10 = (0.101100)2
0.692 × 2 = 1.384 1 ↓
0.384 × 2 = 0.768 0 ↓
0.768 × 2 = 1.536 1 ↓
0.536 × 2 = 1.72 1 ↓
0.72 × 2 = 0.144 0 ↓
0.144 × 2 = 0.288 0 ↓
Answer:
• (0.8125)10 = ( ? )2
• Solution: (0.8125)10 = (_______)2
• (0.8125)10 = (0.1101)2
0.8125 × 2 = 1.6250 1 ↓
0.6250 × 2 = 1.2500 1 ↓
0.2500 × 2 = 0.5000 0 ↓
0.5000 × 2 = 1.0 1↓
• (25.188)10 = ( ? )2
• Solution: (25.188)10 = (_______)2
• ∴ (25.188)10 = (11001.001100)2
2 25 0.188 × 2 = 0.376 0 ↓
2 12 1 ↑ 0.376 × 2 = 0.752 0 ↓
2 6 0 ↑ 0.752 × 2 = 1.504 1 ↓
2 3 0 ↑ 0.504 × 2 = 1.8 1 ↓
2 1 1 ↑ 0.8 × 2 = 0.16 0 ↓
0 1 ↑ 0.16 × 2 = 0.32 0 ↓
2. Binary to Decimal Conversion
Decimal Octal
Binary Hexadecimal
Binary to Decimal Conversion
• Technique
Bit “0”
1010112 => 1 x 20 = 1
1 x 21 = 2
0 x 22 = 0
1 x 23 = 8
0 x 24 = 0
1 x 25 = 32
4310
If Binary number is 111.111, follow the given procedure as under.
=7 + (0.875)
=7.875
(111.111)2 = (7.875)10
Practice: 1
• 1001012 = ( )10
Answer:
• (100101)2 = ( ? )10
• Solution: (100101)2 = (_______)10
100101
=1×25+0×24+0×23+1×22+0×21+1×20
=1×32 +0×16 +0×8 +1×4 +0×2 +1×1
=37
∴ (100101)2 = (37)10
Practice: 2
• 100011102 = ( )10
Answer:
• (10001110)2 = ( ? )10
• Solution: (10001110)2 = (_______)10
10001110
=1×27+0×26+0×25+0×24+1×23+1×22+1×21+0×20
=1×128 +0×64 +0×32 +0×16 +1×8 +1×4 +1×2 +0×1
=142
∴ (10001110)2 = (142)10
More examples:
• Find decimal equivalent of following binary numbers:
(i) 111101000 = ( )10
(ii) 10110101 = ( )10
(iii) 1010.1010 = ( )10
(iv) 1111.1111 = ( )10
(v) 1100.1100 = ( )10
Answers:
• Find binary equivalent of following decimal numbers:
(i) 1111010002 = 48810
(ii) 101101012 = 18110
(iii) 1010.1010 = 10.62510
(iv) 1111.1111 = 15.9410
(v) 1100.1100 = 12.7510
Answers:
• (111101000)2 = ( ? )10
• Solution: (111101000)2 = (_______)10
111101000
=1×28+1×27+1×26+1×25+0×24+1×23+0×22+0×21+0×20
=1×256 + 1×128 + 1×64 + 1×32 + 0×16 + 1×8 + 0×4 + 0×2 + 0×1
=488
∴ (111101000)2 = (488)10
Answers:
• (10110101)2 = ( ? )10
• Solution: (10110101)2 = (_______)10
10110101
=1×27+0×26+1×25+1×24+0×23+1×22+0×21+1×20
=1×128 + 0×64 + 1×32 + 1×16 + 0×8 + 1×4 + 0×2 + 1×1
=181
∴ (10110101)2 = (181)10
Answers:
• (1010.1010)2 = ( ? )10
• Solution:(1010.1010)2 = (_______)10
1010.1010
=1×23 +0×22 +1×21 +0×20 +1×2-1 +0×2-2 +1×2-3 +0×2-4
=1×8 + 0×4 + 1×2 + 0×1 + 1×0.5 + 0×0.25 + 1×0.125 + 0×0.0625
=10.625
∴ (1010.1010)2 = (10.625)10
Answers:
• (1111.1111)2 = ( ? )10
• Solution: (1111.1111)2 = (_______)10
1111.1111
=1×23+1×22+1×21+1×20+1×2-1+1×2-2+1×2-3+1×2-4
=1×8 + 1×4 + 1×2 + 1×1 + 1×0.5 + 1×0.25 +1×0.125 + 1×0.0625
=15.94
∴ (1111.1111)2 = (15.94)10
Answers:
• (1100.1100)2 = ( ? )10
• Solution: (1100.1100)2 = (_______)10
1100.1100
=1×23 +1×22 +0×21 +0×20 +1×2-1 +1×2-2 +0×2-3 +0×2-4
=1×8 +1×4 +0×2 +0×1 +1×0.5 +1×0.25 +0 +0
=12.75
∴ (1100.1100)2 = (12.75)10
3. Decimal to Octal Conversion
Decimal Octal
Binary Hexadecimal
Decimal to Octal Conversion
8 1234
154 2
8
19 2
8
2 3
8
0 2
123410 = 23228
If decimal number is fraction, it is multiplied by 8 successively and
carry is written aside. The carry is read from top to bottom and is
written from left to right after the octal point.
(0.32)10 = (?)8
(0.32) 10 = (0.2436)8
Practice: 1
• Find the octal equivalent of decimal 3542
• ∴ (3542)10 = (6726)8
Practice: 2
• Find the binary equivalent of decimal 0.456
• ∴ (0.456)10 = (0.351361)8
More examples:
• Find octal equivalent of following decimal numbers:
(i) 2196
(ii) 4735
(iii) 0.69
(iv) 0.812
(v) 2562.86
Answers:
• Find octal equivalent of following decimal numbers:
(i) 2196 = (4224)8
(ii) 4735 = (11177)8
(iii) 0.69 = (0.541217)8
(iv) 0.812 = (0.637574)8
(v) 2562.86 = (5002.670243)8
• (2196)10 = ( ? )8 8 2196
• Solution: 8 274 4 ↑
(2196)10 = (_______)8 8 34 2 ↑
8 4 2 ↑
0 4 ↑
• ∴ (2196)10 = (4224)8
• (4735)10 = ( ? )8 8 4735
• Solution: 8 591 7 ↑
8 73 7 ↑
(4735)10 = (_______)8
8 9 1 ↑
8 1 1 ↑
0 1 ↑
• ∴ (4735)10 = (11177)8
• (0.812)10 = ( ? )8 0.812 × 8 = 6.496 6 ↓
0.496 × 8 = 3.968 3 ↓
• Solution: 0.968 × 8 = 7.744 7 ↓
(0.812)10 = (_______)8 0.744 × 8 = 5.952 5 ↓
0.952 × 8 = 7.616 7 ↓
0.616 × 8 = 4.928 4 ↓
• ∴ (0.812)10 = (0.637574)8
• (2562.86)10 = ( ? )8
• Solution:
(2562.86)10 = (_______)8
• ∴ (2562.86)10 = (5002.670243)8
• (0.69)10 = ( ? )8 0.69 × 8 = 5.52 5 ↓
0.52 × 8 = 4.16 4 ↓
• Solution:
0.16 × 8 = 1.28 1 ↓
(0.69)10 = (_______)8 0.28 × 8 = 2.24 2 ↓
0.24 × 8 = 1.92 1 ↓
0.92 × 8 = 7.36 7 ↓
• ∴ (0.69)10 = (0.541217)8
4. Octal to Decimal Conversion
Decimal Octal
Binary Hexadecimal
Octal to Decimal Conversion
• Technique
7248 => 4 x 80 = 4
2 x 81 = 16
7 x 82 = 448
46810
If Octal number is 0.536, follow the given procedure as
under.
=0.68359375
(0.536)8 = (0.68359375)10
5. Decimal to Hexadecimal
Decimal Octal
Binary Hexadecimal
Decimal to Hexadecimal Conversion
16 1234
16 77 2
16 4 13 = D
0 4
123410 = 4D216
If decimal number is fraction, it is multiplied by 16 successively and
carry is taken out. The carry is read from top to bottom and is written
from left to right after the hexadecimal point.
(0.35)10 = (?)16
stopping here,
(0.35) 10 = (0.5999) 16
6. Hexadecimal to Decimal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Decimal
• Technique
=227.[0.77734375]
=227. 77734375
Decimal Octal
Binary Hexadecimal
Binary to Octal
• Technique
• Group bits in threes, starting on right
• Convert to octal digits
Example:
10110101112 = ?8
1 3 2 7
10110101112 = 13278
(1101.1001)2 = (?)8
001 101 . 100 100
added 0 added 0
1 5 . 4 4
(1101.1001) 2= (15.44) 8
8. Binary to Hexadecimal
Decimal Octal
Binary Hexadecimal
Binary to Hexadecimal
• Technique
• Group bits in fours, starting on right
• Convert to hexadecimal digits
Example
10101110112 = ?16
10 1011 1011
2 B B
10101110112 = 2BB16
In case of a fraction number, groups are written on right hand side of
the binary digit.
For example,
(1111011101.1011101)2 = (?)16
(1111011101.1011101)2 = (3DD.BA) 16
9. Octal to Binary Conversion
Decimal Octal
Binary Hexadecimal
Octal to Binary Conversion
• Technique
• Convert each octal digit to a 3-bit equivalent binary
representation
Example
7058 = ?2
7 0 5
7058 = 1110001012
If octal is a fraction number then also the same method is
adopted.
(0.326)8 = (?)2
3 2 6
011 010 110
(0.326) 8= (0.011 010 110) 2
(17.625) 8 = (?) 2
1 7 . 6 2 5
001 111 . 110 010 101
(17.625) 8 = (001 111.110 010 101) 2
10. Hexadecimal to Binary Conversion
Decimal Octal
Binary Hexadecimal
Hexadecimal to Binary Conversion
• Technique
• Convert each hexadecimal digit to a 4-bit equivalent binary
representation
Example
10AF16 = ?2
1 0 A F
10AF16 = 00010000101011112
Convert 3EF.2C into binary
(3EF.2C) 16= (?) 2
3 E F . 2 C
Decimal Octal
Binary Hexadecimal
Octal to Hexadecimal
• Technique
• Use binary as an intermediary
• For this octal number is converted into binary number.
• Then groups of 4 binary numbers are formed.
• And it is converted into hexadecimal number.
Example
10768 = ?16
1 0 7 6
1. Octal to binary conversion
10768 = 23E16
12. Hexadecimal to Octal
Decimal Octal
Binary Hexadecimal
Hexadecimal to Octal
• Technique
• (Use binary as an intermediary)
• For this first hexadecimal number is converted into
binary.
• Then group of 3 are formed.
• Then it is converted into octal.
Example
1F0C16 = ?8
1 F 0 C
1. Hexadecimal to binary conversion
1F0C16 = 174148
Table (1 of 3)
Hexa-
Decimal Binary Octal decimal
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
Table (2 of 3)
Hexa-
Decimal Binary Octal decimal
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
Table (3 of 3)
Hexa-
Decimal Binary Octal decimal
16 10000 20 10
17 10001 21 11
18 10010 22 12
19 10011 23 13
20 10100 24 14
21 10101 25 15
22 10110 26 16
23 10111 27 17
Conversions:
1. Decimal to Binary 7. Binary to octal
2. Binary to decimal 8. Binary to hexadecimal
3. Decimal to octal 9. Octal to hexadecimal
4. Octal to decimal 10. Octal to binary
5. Decimal to hexadecimal 11. Hexadecimal to octal
6. Hexadecimal to decimal 12. Hexadecimal to binary
Examples:
1. Decimal to Binary : 267 =
2. Binary to decimal : 1011.1101 =
3. Decimal to octal : 986 =
4. Octal to decimal : 654 =
5. Decimal to hexadecimal : 267 =
6. Hexadecimal to decimal : ABC =
Examples:
7. Binary to octal : 1011.1101 =
8. Binary to hexadecimal : 101101.101101 =
9. Octal to hexadecimal : 432 =
10. Octal to binary : 675 =
11. Hexadecimal to octal: 12AB =
12. Hexadecimal to binary: 11CD =
Arithmetic operation with binary number:
Binary addition:
101101
010010 (1’s complement)
+ 1 (Add 1)
010011 (2’s complement)
BINARY SUBTRACTION USING 1’S COMPLEMENT:
A) When smaller number has to be subtracted from large number:
1011 1101
+ 1 + 1100
1100 11001
avoid carry (1001) 2
B) When number to be subtracted is larger:
E.g. (1001)2-(1101)2
0010 1001
+ 1 +0011
0011 1100
0011+1=0100 is (-100)2
9’s and 10’s complement:
- These are the complements in decimal number system.
- To find 9’s complement of a decimal number system, each
decimal digit is subtracted from 9.
999
- 307
692
10’s complement of decimal number can be found by adding 1 to the 9’s
complement of that number.
10’s complement = 9’s complement + 1
999
-572
427 (9’s complement)
+ 1 (Add 1)
428 (10’s complement)
Subtraction using 10’s complement
• A) When number to be subtracted is smaller:
1.Write 10’s complement of smaller number.
2. Add it to the large number.
3. Avoid carry. (In this always carry is there)
5
+ 3 (Add 3)
8 (Find binary of 8)
(1000)Ex-3
12
- 3 (Subtract 3)
9
Examples:
• Find BCD code of (83)10 • Find excess-3 code of (1532)10
(83)10 (1 5 3 2)10
Reflective code:
The code in which code of 9 is the complement of the code for
0,code of 8 is the complement of the code for 1and so on is called
the reflective code.
E.g. 2421, 5211, etc.
Alpha-numeric code:
In computers in addition to the numbers, letters(upper case and
lower case),signs, mathematical signs, punctuations etc. are also
used. code is also needed for all these. For this alpha-numeric code is
developed. There are three types of alpha-numeric code:
Even parity: