Binary Codes



Content "filtered", Please subscribe for FULL access.


Chapter 3 : Binary Codes



Binary Arithmetic’s arrow_upward


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

  • Addition:

  • The following are basic rules for binary addition:
    • 0+0=0
    • 0+1=1
    • 1+0=1
    • 1+1=0+carry of 1
    • 1+1+1=1+carry of 1

    For example:

  • 1110 can be added to 1010 as:

  • Subtraction:

  • The following are basic rules for binary subtraction:
    • 0-0=0
    • 10-1=1
    • 1-1=0
    • 1-0=1

    For example:

  • Subtraction of 1011 from 1110 can be done as:

  • Multiplication:

  • The following are basic rules for binary multiplication:
    • 0×0=0
    • 0×1=0
    • 1×0=0
    • 1×1=1

    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:

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

  • 1100÷11 can be done as:

  • 1’s and 2’s Complement arrow_upward



    1’s Complement:

  • 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:

  • 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.
    • Discard carry.
  • 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:

  • Binary Codes arrow_upward


  • 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:
    • Weighted binary code
    • Non- Weighted binary code

    Weighted Binary Code arrow_upward


  • 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 arrow_upward


  • 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 number0111 is represented by its weight to show the decimal 7 because:
  • 0×8+1×4+1×2+1×1 = 7


    2-4-2-1 Code arrow_upward


  • 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.

  • 5-2-1-1 Code arrow_upward


  • 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.

  • Non-Weighted Binary Code arrow_upward


  • 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.

  • Excess-3 Code arrow_upward


  • 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 arrow_upward


  • 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.

  • Binary to Gray Conversion arrow_upward


  • To convert binary number into gray code number, following rules apply:
  • 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.

  • Gray to Binary Conversion arrow_upward


  • To convert Gray number into Binary code number, following rules apply:
  • 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.

  • Relation between Decimal, Binary and Gray Code arrow_upward



    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




    Thank You from Kimavi arrow_upward


  • Please email us at Admin@Kimavi.com and help us improve this tutorial.


  • Mark as Complete

    Kimavi Logo

    Terms and conditions, privacy and cookie policy

    YouTube | Facebook | LinkedIn | Twitter | Pinterest | Vimeo | Google Play | @Email | Paid Subscription
    Science | Engineering | Math | Business | English | Medicine | History | Languages | Law | Animals | Social-Studies | Geography

    Tutorials, Videos and Quizzes - Real Simple Education


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