Number Systems: Module-1:Lecture-6
Number Systems: Module-1:Lecture-6
Number Systems: Module-1:Lecture-6
Module-1:Lecture-6
Number Systems
CONTENTS
Module-1 (Part-1)
Number Systems 2
CONTENTS
Lecture-6
❖ Binary Codes
▪ Weighted Codes
▪ Non-weighted Codes
❖ BCD Arithmetic
Number Systems 3
BINARY CODES
✓ Digital circuits and computer system process data with 0’s and 1’s (i.e., in binary formats)
because of the bistable (two stable states) nature of the digital systems.
✓ However, in actual practice, these circuits are required to handle numeric, alphabetic or
special characters which will be converted into binary form.
✓ For a binary number of n digits, it may be represented by n binary circuit elements whose
output must be 0 or 1.
✓ Therefore, there are various ways to represent any incoming data or information in a digital
system into binary coded form.
✓ In general, the number in a digital system or computer are used in coded form.
✓ There are two types of binary codes
1. Weighted binary codes
2. Non-weighted binary codes
Number Systems 4
WEIGHTED BINARY CODES
Number Systems 5
BCD CODES
Number Systems 6
BCD CODES
Examples
✓ Convert each of these decimal number into BCD code:
1) 35 2) 98 3) 170.2 4) 2469
Solution:
1) 3 5 2) 9 8
3) 1 7 0 . 2 4) 2 4 6 9
Number Systems 7
BCD CODES
Examples
✓ Convert the following BCD codes into decimal equivalent:
1) 10000110 2) 001101010001 3) 1001010001110000
Solution:
1) 1000 0110 2) 0011 0101 0001
8 6 3 5 1
9 4 7 0
Number Systems 8
BCD CODES
9 + 9 + 1 (Previous carry) = 19
✓ The range of the binary sum will be from 0 - 19 i.e., in BCD, it is from 0000 to 00011001 (0000 to
10011 in binary)
✓ Add the two BCD numbers, using the rules for binary addition.
✓ If the sum is equal or less than 1001 (9) without any carry, then the BCD digit is a valid BCD digit.
✓ If sum ≥ 𝟏𝟎𝟏𝟎 (10), then the result is an invalid BCD digit, then add 0110 (6) to the binary sum to get
a valid BCD digit and can also produce a carry as well.
Number Systems 9
BCD CODES
1) 2) 3)
3 0011 8 1000 23 0010 0011
+ 5 + 0101 + 9 + 1001 + 42 + 0100 0010
---- ------ ---- -------- ---- -----------
8 1000 17 1 0001 65 0110 0101
+ 0110
-------- 6 5
1 0111
1 7
Number Systems 10
BCD CODES
Number Systems 11
BCD CODES
Number Systems 12
BCD CODES
Number Systems 13
BCD CODES
Number Systems 14
WEIGHTED BINARY CODES
Number Systems 15
WEIGHTED BINARY CODES
✓ Excess-3 code: these are self complementing codes, i.e., 9’s complement of the decimal
number is obtained by changing 1’s to 0’s and vice-versa.
✓ Example:
Excess-3 Code
4 0 2 0111 0011 0101
9’s Complement 1’s Complement
9 9 9
−4 0 2
1000 1100 1010
5 9 7
− 0011 0011 0011
0101 1001 0111
5 9 7
Number Systems 16
NON-WEIGHTED BINARY CODES
Number Systems 17
GRAY CODES
Number Systems 18
GRAY CODES
Example:
✓ Convert (110111001)2 to gray code.
1 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 1
1 0 1 1 0 0 1 0 1
Number Systems 19
GRAY CODES
Example:
✓ Convert gray code (101110101) to binary code.
1 0 1 1 1 0 1 0 1
+ + + + + + + +
1 1 0 1 0 0 1 1 0
Number Systems 20
GRAY CODES
Number Systems 21
ASCII CODES
Number Systems 22
ASCII CODES
Number Systems 23
ASCII CODES
Number Systems 24
Additional Questions
Question-1: compute
a) 18 + 82 using BCD addition
a) 184 + 419 using BCD addition
Question-2: Convert gray code 10101010111 to binary
Number Systems 25
Number Systems 26