Hello people. I hope all are doing great!

What are codes?

We all know that computers don't understand our language. Be it English or Hindi or anything. They only work with 0's and 1's. So all our messages needs to be converted in a manner that machines can interpret it. That is code!
We all learnt code long ago. Girls will get this. Remember when in school. We all used a secret word to name our crush. Only the best friend knows what it is. Also, there were some girls who used a keyword that is to be placed before and after every word in a sentence. And then they talk in public privately. Like 'en' is the keyword then 'entheen ensentencen enwillen enlooken enlikeen enthisen' That's exactly what we use code for - Secrecy.
Let's check out some secret codes for a computer.

BCD (Binary Coded Decimal)

This is the simplest one. Every decimal digit is replaced by its binary equivalent in four digit.
Let's take the number 81.
8 in binary is 1000
1 in binary is 1. But we have to use four digits. Hence it is 0001.
So binary coded decimal for 81 will be 10000001.

Excess-3 Code (XS3)

As the name suggests, it exceeds every digit of the actual number by 3 and then code it in BCD. 
For the number 77
7 7
+ 3 3
10 10
Now, Binary for 10 is 1010. And hence, the Excess-3 Code for 77 is 10101010.

Gray Code

This one is a bit tricky. Yeah, just a bit. Haha. Stay attentive, friends.
Let's take 3. Its binary is 0011.
For the gray code we will write a completely new binary number. Begin with the first digit of actual binary number. Take 0. Add the next digit of original binary to it. We have now, 00. Adding next digit of binary number 3 to the current digit of gray code. 1 and 0 adds to 1. gray code now becomes 001. Taking next from binary, 1. The current digit in gray code is 1. 1 added to 1 gives 0. The final gray code becomes 0010. (You can check binary addition here.)
I tried explaining with picture below.
Gray Code
I hope it helps! Let's connect on instagram. Follow @naazweb

1 Comments

Did you enjoy reading it? Comment and help me improve.