0% found this document useful (0 votes)
13 views15 pages

Lec05 Number Systems Binary Codes

Uploaded by

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

Lec05 Number Systems Binary Codes

Uploaded by

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

EE213M Digital Circuits

Number Systems – Binary Codes


Binary Logics

16/01/2024 EE213M 1
Signed binary Numbers
• In conventional arithmetic, a negative number is indicated by a “-” sign and a positive number by a “+”
sign.
• In Binary number system a sign bit is used.
• Sign bit is 0 for positive numbers and 1 for negative numbers.
• For unsigned binary numbers (11001)2= (25)10
• For signed binary numbers (11001)2= (-9)10
• This method of representing negative numbers is called as signed-magnitude convention.
• Other method of representing negative numbers using complements is called as signed-complement
conventions

+9 00001001 Same for all conventions


-9 10001001 signed-magnitude convention.
-9 11110110 Signed 1’s complement representation
-9 11110111 Signed 2’s complement representation

16/01/2024 EE213M 2
Numbers Signed Magnitude Signed 1’s complement Signed 2’s complement
Convention representation representation
+7 0111 0111 0111
+6 0110 0110 0110
+5 0101 0101 0101
+4 0100 0100 0100
+3 0011 0011 0011
+2 0010 0010 0010
+1 0001 0001 0001
+0 0000 0000 0000
-1 1001 1110 1111
-2 1010 1101 1110
-3 1011 1100 1101
-4 1100 1011 1100
-5 1101 1010 1011
-6 1110 1001 1010
-7 1111 1000 1001

16/01/2024 EE213M 3
Addition of signed numbers using 2’s Complement
convention
• It is performed addition of the two numbers, including their sign bits.
• A carry out of the sign‐bit position is discarded.

+5 0000 0101 -5 1111 1011


+10 0000 1010 +10 0000 1010
+15 0000 1111 +5 0000 0101
(carry discarded)

+5 0000 0101 -5 1111 1011


-10 1111 0110 -10 1111 0110
-5 1111 1011 -15 1111 0001
(carry discarded)

16/01/2024 EE213M 4
Addition of signed numbers using 2’s Complement
convention
• Overflow Condition
• When the number of bits assigned is not enough to accommodate the sum.

+128 0100 0000 -128 1100 0000


+128 0100 0000 -128 1100 0000
+256 1000 0000 -256 1000 0000
Wrong result (Wrong result)

+128 0 0100 0000 -128 1 1100 0000


+128 0 0100 0000 -128 1 1100 0000
+256 0 1000 0000 -256 1 1000 0000
Correct result (Correct result)

16/01/2024 EE213M 5
Subtraction of signed numbers using 2’s Complement
convention
• Subtractions of signed numbers is same process as addition.
• M – N = M + (-N)

• binary numbers in the signed‐complement system are added and subtracted by the same basic addition
and subtraction rules as unsigned numbers.
• common hardware circuit can handle both types of arithmetic.
• signed‐complement system are mostly used in all arithmetic units of computer systems.

• The user or programmer should have the knowledge that numbers are signed or unsigned

16/01/2024 EE213M 6
Binary Codes
• Information in a digital computer is usually coded rather than binary numbers.
• It is because humans are comfortable in decimal systems and input and output information are mostly in
decimal numbers.

• There are various binary codes available which are as follows:


• Binary coded decimal (BCD) code
• Excess-3 Code
• 2421 Code
• 6311 Code
• Gray Code

16/01/2024 EE213M 7
BCD Code
• In BCD Code, Each decimal number is coded by a string of 4 bits.
Decimal BCD Code
• A string of 4 bits can have maximum 16 possible combinations, so 6 combinations Number
from 1010 to 1111 remain unassigned in BCD code. 0 0000
( 123.45)10 = 0001 0010 0011. 0100 0101 1 0001
2 0010
BCD require more or equal to number of bits to represent a decimal number as 3 0011
Compared to binary numbers. 4 0100
5 0101
6 0110
• BCD numbers are decimal numbers and not binary numbers, although they use
bits in their representation 7 0111
8 1000
9 1001

16/01/2024 EE213M 8
BCD Addition
• When the binary sum is equal to or less than 1001 (without a carry), the corresponding BCD digit is
correct. However,
• when the binary sum is greater than or equal to 1010, the result is an invalid BCD digit.
• The addition of 6 = (0110)2 to the binary sum converts it to the correct digit.
4 0100 184 0001 1000 0100
5 0101 520 0101 0010 0000
9 1101 704 0110 1010 0100
1 0110
4 0100
0111 0000 0100
8 1000
12 1100
Add 6 0110
10010

16/01/2024 EE213M 9
Weighted Codes (2421 and 6311 code)
Decimal BCD Code 2421 Code 6311 Code
Number 8421 code
• Similar to BCD code, Each decimal number is
represented by 4 bits. 0 0000 0000 0000
• Each position from MSB to LSB is having certain 1 0001 0001 0001
weights. that’s why called as weighted codes. 2 0010 0010 0011
• 2421 codes have the weights of 2,4,2,1 consecutively 3 0011 0011 0100
from MSB to LSB. 4 0100 0100 0101
• 6311 code will have the weights of 6,3,1,1 5 0101 1011 0111
consecutively from MSB to LSB.
6 0110 1100 1000
7 0111 1101 1001
• Some digits Can be coded by two different ways in 8 1000 1110 1011
2421 code and 6311 code.
9 1001 1111 1100

16/01/2024 EE213M 10
Excess-3 Code
• Excess‐3 is an unweighted code. Decimal BCD Code Excess-3
Number 8421 code
• Each coded combination is obtained from the corresponding binary
value plus 3. 0 0000 0011
1 0001 0100

• These are self-complementing codes. 2 0010 0101


3 0011 0110
• 9’s Complement of the decimal digit is obtained by interchanging 1’s
and 0’s 4 0100 0111
• 2 – 0101 5 0101 1000

• 9’s Complement of 2 =7 (1010) 6 0110 1001


7 0111 1010
25 0101 1000 8 1000 1011
74 (9’s Complement) 1010 0111 9 1001 1100

• 2421 code is also self-complementing code.

16/01/2024 EE213M 11
Decimal Binary Gray
Number Number Code
Gray Code 0 0000 0000
1 0001 0001
• It is convenient to use the Gray code to represent digital data that have been
2 0010 0011
converted from analog data.
3 0011 0010
• The advantage of the Gray code is that only one bit in the code group changes in
going from one number to the next. 4 0100 0110
• It is used in applications where hardware may produce an error during transition from 5 0101 0111
one number to next. 6 0110 0101
7 0111 0100
• Conversion from binary number to Gray Code 8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
16/01/2024 EE213M 12
ASCII Character Code
• American Standard Code for Information
Interchange (ASCII)
• Standard binary code for the alphanumeric
characters.
• It uses seven bits to code 128 characters.
• The seven bits of the code are designated by b1
through b7, with b7 the most significant bit.

• A= 1000001

16/01/2024 EE213M 13
Error-Detecting Code
• An Extra bit is used which is 0 or 1 depending upon the number of 1’s in the remaining bits.
• It is called as parity bit.
• This parity bit is added in MSB position to make the total number of 1’s in the character to be even for even parity and
odd for odd parity.

With Even parity With Odd parity


ASCII code A=1000001 01000001 11000001
ASCII code T=1010100 11010100 01010100

• It is helpful in detecting error during transmission.


• It detects only odd combination of error in the each transmitted character.
• After detecting parity error, receiver can request to resend the character until the parity error is not received.

16/01/2024 EE213M 14
Problem sets
• Q. 1 Add the following numbers in binary using 2’s complement.
(i) 18 + (-25) (ii) (-11) + (-21)

• Q. 2 Add the following numbers in binary using 1’s complement.


(i) 21 + (11) (ii) (13) + (-12)

16/01/2024 EE213M 15

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy