Happy Teej - TEEJ2024

# Rules and Tricks For Binary Coding-Decoding

### Introduction

• Binary means only 0(zero) and 1(one).
• Decimal means from 0(zero) to 9(nine).
• In binary, the base is 2.
• In decimal, the base is 10.
• Remember: - 2^0 =1, 2^1 =2, 2^2=4, 2^3=8, 2^4 =16 and so on…

### Binary to decimal conversion:

#### Approach 1

Example: Convert 100 in decimal

Starting from the left end of this number, multiply with the 2^0 then 2^1 and so on. Then add these all.
1*2^2 + 0*2^1 + 0*2^0 = 1*4 + 0*2 + 0*1 =4

#### Approach 2

Write this number 100 and just below it, start writing 2^0, 2^1 and so on from the left end of this number. Then eliminate the number which coincides with zero and then add all left numbers.

100

421
Remove 1 and 2 as it coincides with 0. The left number is our result.

100010---32 16 8 4 2 1, remove those numbers which coincide with zero and then add the left numbers. After removing the numbers, the left numbers are 32 and 2. Add these numbers. After adding we get 34. This is the required decimal number.

### Decimal to binary conversion:

Example: Convert 15 in binary.

One question to make it clear: -

In a certain code, the symbol for 0 is * and for 1 is #.
There are no other symbols for all other numbers greater than one.
The numbers greater than 1 are to be written only by using the two symbols give above.
The value of symbol for 1 doubles itself every time it shifts one place to the left.

• ‘0’ is written as *
• ‘1’ is written as #
• ‘2’ is written as #*
• ‘3’ is written as ##
• ‘4’ is written as #**

1. ‘18’ can be represented as: -

• Convert 18 in binary and then use the given symbols.
• And now use the symbols. So the result will be 10010= #**#*.

2. ‘24’ can be represented as: -

• Again convert 24 in binary and then use the given symbols.
• And now use the symbols. So the result will be 11000= ##***.

3. #*##* can be represented as: -

• So #*##* can be written as 10110 and then it can be converted in decimal if the question is asked in decimal.
• So to convert in decimal the process goes like (1*16 + 0*8 + 1*4 + 1*2 + 0*1) =22.

4. (#*** + #* ÷*#*) can be represented as: -

• First represent this symbol in binary.
• (1000 + 10 ÷010)
• Now convert it in decimal.
• [ (1*8 + 0*4 + 0 *2 + 0*1) + (1*2 + 0*1) ÷ (0*4 + 1*2 + 0*1) ] = [8 + 2 ÷ 2] = 8 + 1 = 9.