0% found this document useful (0 votes)
70 views43 pages

Chap 1number Systems and Codes

Uploaded by

vsjadhav1085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views43 pages

Chap 1number Systems and Codes

Uploaded by

vsjadhav1085
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 43

Digital techniques(22320)

NUMBER SYSTEMS AND CODES

Mrs. M.S. Ranade


HOD Computer Engineering Department
Course outcomes
• Use number systems and codes for interpreting
working of digital system
• Use Boolean expressions to realize logic
circuits
• Build simple combinational circuits
• Build simple sequential circuits
• Test data converters and PLDs in digital
electronics systems
Topics in the curriculum

• Number systems and codes (8)


• Logic gates and logic families (12)
• Combinational logic circuits (18)
• Sequential logic circuits (18)
• Data converters and PLDs (14)
Number systems and codes
• Convert given number into specified number
system
• Perform binary arithmetic operation on given
binary numbers
• Convert given coded number into other
specified code
• Add given two decimal numbers using BCD
code
Number systems
Name of number Base/ Digits used
system Radix
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

In digital systems, instructions are given through electric


signals; variation is done by varying the voltage of the
signal. So, many number systems that are easier to
implement digitally have been developed.
Number systems continued
• All these number systems are positional value number systems.
That is value of digits will depend on its position.
756 = 700+50+6
• The weightage of each position can be represented as follows
Binary 2
4
2
3
2
2
2
1
2
0

Octal 8
4
8
3
8
2
8
1
8
0

Decimal 10
4
10
3
10
2
10
1
10
0

Hexadecimal 16
4
16
3
16
2
16
1
16
0
Conversion of Decimal number to
other number systems
Decimal to Binary Decimal to Octal Decimal to Hex
25 47 79
2 12 1 (LSB) 8 5 7 LSD 16 4 15(F)
2 6 0 8 0 5 16 0 4

2 3 0 MSD
2 1 1
2 0 1 (MSB)

(25)10 = (11001)2 (47)10 = (57)8 (79)10 = (4F)16

Decimal numbers can be converted to other number systems by


repeated division of the number by base/radix of respective number
system while recording the remainder. Repeat division until
quotient equal to zero
Conversion of Decimal fraction to
other number systems
Decimal to Binary Decimal to Octal Decimal to Hex

0.625 * 2 = 1.25 0.3125 * 8 = 2.5 0.45 *16 = 7.2


0.25 * 2 = 0.5 0.5 * 8 = 4.0 0.2 * 16 = 3.2
0.5 * 2 = 1.0 0.2 * 16 = 3.2

(0.625)10 = (0.101)2 (0.3125)10 = (0.24)8 (0.45)10 = (0.733...)16

• Multiply the fraction by base.


• Consider the integer as coefficient.
• Take resultant fraction and repeat the procedure.
Conversion of other number to
Decimal number systems
• Binary to Decimal
(11010)2 = 1*24+1*23+0*22+1*21+0*20 =16+8+0+2+0
(11010)2 = (26)10
• Octal to Decimal
(273)8 = 2*82+7*81+3*80 =128+56+3
(273)8 = (187)10
• Hex to Decimal
(9B)16 = 9*161+11*160 =144+11
(9B)16 = (155)10
Conversion of fractions of other number
system to Decimal number systems
• Binary to Decimal
(11.01)2 = 1*21+1*20+0*2-1+1*2-2 =2+1+0+0.25
(11.01)2 = (3.25)10
• Octal to Decimal
(73.25)8 =7*81+3*80 + 2*8-1+5*8-2 =56+3+0.25+0.078125
(73.25)8 = (59.328125)10
• Hex to Decimal
(9B.5)16 = 9*161+11*160 +5 * 16-1=144+11+0.3125
(9B)16 = (155.3125)10
Conversion of other number to
Decimal number systems continued

To convert binary, octal and hexadecimal to


decimal number, we just need to add the
product of each digit with its positional value.
Number System Relationship
Hexadecimal Decimal Octal Binary
0 0 0 0000
1 1 1 0001
2 2 2 0010
3 3 3 0011
4 4 4 0100
5 5 5 0101
6 6 6 0110
7 7 7 0111
8 8 10 1000
9 9 11 1001
A 10 12 1010
B 11 13 1011
C 12 14 1100
D 13 15 1101
E 14 16 1110
F 15 17 1111
Conversion of Binary number to Octal
number and vice versa
• Starting from the least significant bit, make groups of
three bits.
• If there are one or two bits less in making the groups,
0s can be added before the most significant bit
• Convert each group into its equivalent octal number

Octal Digit 0 1 2 3 4 5 6 7

Binary
000 001 010 011 100 101 110 111
Equivalent
Conversion of Binary number to Octal
number and vice versa continued
10101110
(403)8 = (100000011)2
010 101 110

2 5 6 (371)8 = (11111001)2
(10101110)2 = (256)8

Octal to binary
Binary to octal
Conversion of Binary number to
Hexadecimal number and vice versa

• Starting from the least significant bit, make groups of


four bits.
• If there are one or two bits less in making the groups,
0s can be added before the most significant bit.
• Convert each group into its equivalent hexadecimal
number
Conversion of Binary number to Hex
number and vice versa continued
10110110111

0101 1011 0111 (6C8)16 = (11011001000)2

5 B 7

(10110110111)2 = (5B7)16 (E0A)16 = (111000001010)2


Conversion of Octal number to
Hexadecimal number and vice versa
• Direct conversion of octal to hex or hex to octal is not
possible
• We have to convert
Octal to binary and then binary to hex
or
Octal to decimal and then decimal to hex
(652)8 = (?)16
(652)8 = (110101010)2 (0001 1010 1010)2 = (1AA)16
(CAD)16 = (?)8
(CAD)16 = (110010101101)2 (110 010 101 101)2 = (6255)8
Binary Arithmetic

Binary arithmetic is essential part of all the digital


computers and many other digital systems.
Binary addition
Binary subtraction
Binary multiplication
Binary division
Binary addition
Rules of binary addition

A B Sum Carry
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1

• 1 + 1 + 1 = 11(sum 1 carry 1)
Binary addition continued
1010 10110 10110110 A
+1001 +01111 + 01011100 B
------------ ------------ ------------------
1 1111 111111 carry
------------ ------------ ------------------
10011 1 0 0 1 0 1 1 0 0 0 1 0 0 1 0 result
Binary subtraction
Rules of binary subtraction

A B Difference(A-B) borrow

0 0 0 0
0 1 1 1

1 0 1 0

1 1 0 0
Binary subtraction continued
1 10
0 10 0 10 10 0 10 0 0 10 Borrow

------------ ------------- -------------------


1011 10010 10110110 A
- 0111 - 01110 - 01011100 B
------------ ------------ ------------------
0100 00100 0 1 0 1 1 0 1 0 result
Binary multiplication
Binary multiplication is similar to decimal multiplication.
It is simpler than decimal multiplication because only 0s
and 1s are involved.
1001 1101
x 101 x 1001
----------------- --------------------
1001 1101
0000 0000
+ 1001 0000
----------------- + 1101
101101 -----------------------
1110101
Binary division
Binary division is similar to decimal division.
101 101
101 11001 11 1111
- 101 - 11
------- -----
0010 001
- 0000 - 000
-------- -------
00101 0011
- 00101 - 0011
---------- --------
00000 0000
1’s complement and 2’s complement
• Complements are used in digital systems to simplify
subtraction operation and also to represent negative
numbers

• 1’s complement of a number is obtained by replacing


all 1’s by 0’s and all 0’s by 1’s

• Example given number 101001 10110


1’s complement 010110 01001
1’s complement and 2’s complement
continued
• 2’s complement of a number is obtained by adding 1
to least significant bit (LSB) of 1’s complement of
that number
• 2’s complement = 1’s complement + 1
• Example given number 101001
1’s complement 010110
add 1 1
----------
2’s complement 010111
Subtraction using 1’s complement
Steps to be followed for subtraction (A-B)
1.Convert the number to be subtracted (B) to its 1’s
complement
2.Add A and 1’s complement of B using rules of binary
addition
3.If final carry is 1, add it to the result of addition obtained
by step 2. Final carry 1 means subtraction is positive and it
is in its true form
4. If final carry obtained by step 2 is 0, result obtained by
step 2 is negative and it is in 1’s complement form.
Complement it to obtain true form
Subtraction using 1’s complement
continued
10111 - 11000
1’s complement of 11000 is 00111
10111
+00111
----------
111
----------
0 11110
0 carry indicates result is negative and it is in 1’s
complement form
Final answer is 00001
Subtraction using 1’s complement
continued
11001 – 1010
1’s complement of 01010 is 10101
11001
+ 10101
----------
1
----------
1 01110
+ 1
-----------
01111
Subtraction using 2’s complement
Steps to be followed for subtraction (A-B)
1.Convert the number to be subtracted (B) to its 2’s
complement
2.Add A and 2’s complement of B using rules of binary
addition
3.If final carry is 1, discard it. Final carry 1 means
subtraction is positive and it is in its true form
4. If final carry obtained by step 2 is 0, result obtained by
step 2 is negative and it is in 2’s complement form. Convert
it to true form
Subtraction using 2’s complement
continued
11010 - 11110
1’s complement of 11110 is 00001
2’s complement is 00010
11010
+00010
----------
1
----------
0 11100
0 carry indicates result is negative and it is in 2’s complement
form
Final answer is 2’s complement of 11100 i.e. 00100
Subtraction using 2’s complement
continued
11001 – 1010
1’s complement of 01010 is 10101
2’s complement is 10110
11001
+ 10110
----------
1
----------
1 01111
Discard the carry
Codes
Computers and other digital circuits process digital data.
Digital data is represented , stored and transmitted as a
group of binary digits. Such group of binary digits is
called as binary code. Different types of binary codes
are used to represent data. Commonly used codes are
•Straight binary code
•BCD code
•Excess-3 code
•Gray code
•ASCII code
Codes continued
Straight binary code
• This is weighted code
• This code is used to represent numbers in
natural/straight binary form
• Various arithmetic operations can be performed in this
form
Codes continued
BCD (binary coded decimal)code
• This code is also known as 8421 code
• It is weighted code
• Arithmetic operations can be performed using this code
• In this code decimal numbers 0 through 9 are represented/coded
by their natural binary equivalent using 4 bits
• Each decimal digit of a decimal number is represented by this 4
bit code
• Example (21)10 BCD code 0010 0001
binary code 10101
• It is very convenient and useful code for i/o operations in digital
systems
Codes continued
Excess-3 code
• This is another form of BCD code
• This is non weighted code
• Here each decimal digit is coded into 4 bit binary
code
• Code for each decimal digit is obtained by adding
decimal 3 to BCD code of a digit
• Example (7)10 BCD code 0111
Excess-3 code 1010
Codes continued
Gray code
• This is non weighted code
• In this code decimal number is represented in binary
form such that each gray code number differs from
preceeding and succeeding number by a single bit
• Example gray code for (5)10 is 0111
gray code for (6)10 is 0101
Decimal Binary BCD Excess-3 Gray
0 0000 0000 0011 0000
1 0001 0001 0100 0001
2 0010 0010 0101 0011
3 0011 0011 0110 0010
4 0100 0100 0111 0110
5 0101 0101 1000 0111
6 0110 0110 1001 0101
7 0111 0111 1010 0100
8 1000 1000 1011 1100
9 1001 1001 1100 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
Codes continued
ASCII code
• Digital systems handle data which consists of numerals,
alphabets and special symbols
• Hence it is necessary to have binary codes for this data
• ASCII code is used to assign binary value to letters
numbers and other characters
• If n bit binary code is used we can represent 2n elements
using this code
• It is 7 bit code used to represent 128 different
alphanumeric values
BCD addition
Rules for BCD addition
1.Add two BCD numbers using rules for binary addition
2.If 4 bit sum is equal to or less than 9, it is a valid BCD
number
3.If 4 bit sum is greater than 9 or if a carry is generated out of
a group, it is invalid result. Add 6(0110)2 to the 4 bit sum as
correction factor to skip 6 invalid BCD states and produce
valid BCD code. If carry is generated due to addition of
correction factor, simply add it to the next 4 bit group
BCD addition continued
Perform BCD addition 64 + 32
64 0110 0100
+32 +0011 0010
---- ---------------
96 11
---------------
1001 0110
BCD addition continued
Add (58)10 + (75)10
58 0101 1000
+ 75 + 0111 0101
----- --------------
133 111
---------------
1100 1101 both groups are invalid
+ 0110 0110
---------------
1 1 1 1
---------------
0001 0011 0011
BCD addition continued
Add (59)10 + (29)10

59 0101 1001
+ 29 + 0010 1001
------ -----------------------
88 1111 1
-----------------------
1000 0010 right group is invalid
+ 0110 BCD because of carry
----------------
11
-----------------
1000 1000

You might also like