Binary Codes

Content "filtered" , Please subscribe for FULL access.

Topics covered in this snack-sized chapter:

The arithmetic operation such as addition, subtraction, multiplication and division are performed.

The following are basic rules for binary addition:
For example:

1110 can be added to 1010 as:

The following are basic rules for binary subtraction:
For example:

Subtraction of 1011 from 1110 can be done as:

The following are basic rules for binary multiplication:
For example:

Multiplication is done in the same manner as with decimal numbers which involves forming partial products, shifting each successive partial product to one place left and then adding all partial products.

Division in binary is same as in decimal number system.
For example:

1100÷11 can be done as:

1’s complement of a number is obtained by changing all 1’s to 0’s and vice versa as shown below:
Binary Number

1’s Complement

1100010

0011101

1’s complement subtraction:

Binary number subtraction using 1’s complement form is performed as follows (for smaller number from larger number)
Find the 1’s complement form of the subtrahend.
Add this 1’s complement to other number.
Remove the carry and add it to the result, the carry is called end around carry.
For Example:

To subtract 10101 from 11101

When subtracting larger number, from the smaller one the answer has an opposite sign and is the 1’s complement of the result.
For Example:

To subtract 1100 from 1000

2’s complement of a binary number is obtained by simply adding 1 to 1’s complement of that number.
Binary Number

1’s complement

2’s complement

1011

0100

0100+1=0101

2’s complement subtraction:

For subtracting a smaller number from larger one the method is as follows:
Find the 2’s complement of the smaller number.
Add 2’s complement to larger number.

For example, 1001 can be subtracted from 1100 as follows:

For subtracting a larger number from smaller one the method is as follows:
Find the 2’s complement of the larger number.
Add this 2’s complement to smaller number.
The answer has a negative sign and is 2’s complement form.
Now take the 2’s complement and change the sign.
For Example:

1100 can be subtracted from 1000 as follows:

A binary code represents text or computer processor instructions using the binary number system's two binary digits, 0 and 1.

There are two types of binary codes:
Non- Weighted binary code

In weighted binary system, each position of the number represents a specific weight.
Binary coded decimal (BCD), , code are example of weighted binary code.

BCD code is used to represent each of the 10 decimal digits, as a 4 bit binary code.

It is also known as 8-4-2-1 code.

It is very useful code for input and output operations in digital circuits.

For example: To convert (27)_{10
} to BCD each decimal digit is assigned to its binary equivalent as:
Decimal

2

7

BCD

0010

0111

(27)_{10
} = (00100111)_{BCD
}

The binary number 0111 is represented by its weight to show the decimal 7 because:
0×8+1×4+1×2+1×1 = 7

A decimal number is represented in 4-bit form and the total weight of four bits is 2 + 4 + 2 + 1 = 9.

Hence the 2421 code represents the decimal numbers from 0 to 9.

A decimal number is represented in 4-bit form and the total weight of four bits is 5 + 2 + 1 + 1 = 9.

Hence the 5211 code represents the decimal numbers from 0 to 9.

Codes that are not positional weighted are known as Non-weighted binary code.

Excess-3 code and Gray code are example of Non-weighted binary code.
It is also a bit code and can be derived from BCD code by adding to each coded number.

For example, to encode the decimal digit 5 into excess-3 code, 3 is added to 5 to get 8, then this eight is encoded in its equivalent 4-bit binary code 1000.

6 in Excess-3 is 9.
Decimal

Binary

6

0110

+3

0011

Excess-3=9

1001

Gray code belongs to a class of codes known as minimum-change codes.

The reflected binary code, also known as Gray code, is a binary numeral system where two successive values differ in only one bit. It is a non-weighted code.

To convert binary number into gray code number, following rules apply:
MSB in the gray code is the same as corresponding digit in binary number.
Starting from left to right add each adjacent pair of binary digit to get the next gray code digit, discard carries if generated.
For Example:

Convert binary number 1001 into gray code.
Solution:

The MSB in the gray code is same as corresponding digit (MSB) of binary number.
1

0

0

1

Binary

1

Gray

Add the leftmost binary digit to the adjacent one.
1 +

0

0

1

Binary

1

1

Gray

Add next adjacent pair.
1

0 +

0

1

Binary

1

1

0

Gray

Add last adjacent pair.
1

0

0 +

1

Binary

1

1

0

1

Gray

Hence gray code for binary 1001 is 1101.

To convert Gray number into Binary code number, following rules apply:
MSB in the binary code is the same as corresponding digit in gray number.
Starting from left to right Ex-or each binary digit generated by the gray digit to the next gray digit.

For example: Convert gray code 1101 into binary code.
1

1

0

1

Gray

1

Binary

1

1

0

1

Gray

1

0

Binary

1

1

0

1

Gray

1

0

0

Binary

1

1

0

1

Gray

1

0

0

1

Binary

Hence binary code for gray 1101 is 1001.
Decimal

Binary

Gray

0

0000

0000

1

0001

0001

2

0010

0011

3

0011

0010

4

0100

0110

5

0101

0111

6

0110

0101

7

0111

0100

8

1000

1100

9

1001

1101

10

1010

1111

11

1011

1110

12

1100

1010

13

1101

1011

14

1110

1001

15

1111

1000

Mark as Complete

Subscription Required! To track progress and receive a certification in Digital-Electronics you need an active subscription!
×

Create Videos & Quizzes
Tutorials, Videos and Quizzes - Real Simple Education

humanSuccess = (education) => { `Life, Liberty, and the pursuit of Happiness` }