Number Systems: Module-1:Lecture-6

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

DIGITAL LOGIC DESIGN

(Course Code: ECE 1003)

Module-1:Lecture-6
Number Systems
CONTENTS

Module-1 (Part-1)

❖ Number systems and conversions


❖ Binary arithmetic operations
❖ r’s and (r-1)’s compliment
❖ Binary signed and unsigned numbers
❖ Weighted and non-weighted binary codes

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

✓ In weighted binary codes, each digit is associated with some weights.


✓ Each bit position is assigned a weighing factor and each digit is evaluated by adding the
weights of all the ones in the coded combination
✓ There are various types of weighted binary codes
▪ Binary Coded Decimal (BCD Code)
▪ 2421 Code
▪ Excess-3 Code
▪ 84-2-1 Code

Number Systems 5
BCD CODES

✓ This another way to represent decimal numbers.


✓ As this is weighted code, each successive digits
from right to left represents weights equal to
some specified value. Most commonly the BCD
code is 8421.
✓ To get the equivalent decimal number, we sum
the products of these weights with corresponding
binary digit.
✓ Decimal numbers 0 – 9 can be represented using
4 binary bits using 8421 code.
✓ There are 6 unused combinations in this coding
scheme.

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

0011 0101 1001 1000

3) 1 7 0 . 2 4) 2 4 6 9

0001 0111 0000 . 0010 0010 0100 0110 1001

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

3) 1001 0100 0111 0000

9 4 7 0

Number Systems 8
BCD CODES

Addition Operation of BCD Codes


✓ During the addition of two decimal digits using BCD codes, the sum can’t be greater than

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)

Method for BCD addition

✓ 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

Example-1: Perform the following using BCD addition


1) 3 +5 2) 8+9 3) 23 + 42
Solution:

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

Example-2: Perform the following using BCD addition


1) 167 + 482 2) 893 + 487
Solution:
1 2) 1 1
1)
167 0001 0110 0111 893 1000 1001 0011
+ 482 + 0100 1000 0010 + 487 + 0100 1000 0111
------ ----------------- ------ ------------------
649 0110 1110 1001 1380 1101 0010 1010
+ 0110 + 0110 0110 0110
------------------- --------------------
0110 0100 1001 1 0011 1000 0000
6 4 9 1 3 8 0

Number Systems 11
BCD CODES

Number Systems 12
BCD CODES

Number Systems 13
BCD CODES

Number Systems 14
WEIGHTED BINARY CODES

✓ Other weighted binary


codes are:
▪ 2421 Code
▪ Excess-3 Code
▪ 84-2-1 Code

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

✓ Weight is not assigned to the bit positions.


✓ Different types of non-weighted codes are
▪ Gray Code
▪ ASCII Code

Number Systems 17
GRAY CODES

✓ Gray codes are generally used during the conversion


of continuous analog data to digital data.
✓ Advantage of gray code over binary number
sequence is that only one bit in the group changes in
going from one number to the next.
✓ This code is useful to avoid the errors or ambiguity
during transformation from one number to the next.

Number Systems 18
GRAY CODES

Conversion of Binary to Gray code


✓ Record the MSB
✓ Add this MSB to the next bit. Neglecting the carry if any, record the sum.
✓ Continue recording sums until LSB is reached.

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

Conversion of Gray to Binary code


✓ Record the MSB
✓ Add this binary MSB to the next significant bit of the gray code.
✓ Ignoring carries record the result, continue this process until LSB is reached.

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

✓ It is used to represent numbers, special characters, alphabets or symbols.


✓ ASCII- American Standard Code for Information Interchange
✓ ASCII is 7-bit code but most computer manipulate an 8-bit quantity as a single unit.
✓ It is used to code 128 characters.
✓ 94 graphic characters – printed ( A-Z, a-z, 0-9, @, !, #, $, *, &, etc.)
✓ 34 non-printed characters (e.g., ESC, DEL, SP, etc.)

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

You might also like