Binary Repersentation
Tags: beginners, binary
Published: 2022-09-13 15:09:06

You can go around talking about your D&D obsession and your favorite Anime that no one has even heard of and how you just binged watched all The Hobbit, but if you truely want to embrace the title of 'that one nerdy kid' in your class, amidst your group of friends or even amongst your family, then you need to know how to work with binary.

First thing you should know about binary is that it's not it's own seperate language, it's a simple number representation system consisting of two symbols: 0 and 1. It's not very different from the numbers that we use daily, both binary(base-2) and decimals(base-10), what we call the number system that goes from 0-9) are number representation systems. Using 0's and 1's, we can represent any base-10 number to communicate information.
To convert base-10 numbers into base-2(binary) numerical represantation, we have to do simple division with a little bit of a twist. For example, if we want to to convert 27 to binary we have to repetitivly divide it by 2 until we reach a remainder of 0 or 1. The twist here is that everytime we divide it by 2 we note the remainder, take the quotient from the division and continue the process by dividing it by 2. This same process is repeated after the division of each quotient until all we have is a string of remainders that are 1's and 0's. However, to correctly read the order of 1's and 0's, you have to go backwards: starting from most recent remainder to the very first remainder that you got from your first division.

If that was a little too much at once, here is a simple step by step process of how to do it.

Step 1: Divide the given decimal number by 2 and note down the remainder.

Step 2: Now, divide the obtained quotient by 2, and note the remainder again.

Step 3: Repeat the above steps until you get 0 as the quotient.

Step 4: Now, write the remainders in such a way that the last remainder is written first, followed by the rest in the reverse order. 

Each 0 and 1 is considered to be a bit, and 8 bits is 1 byte.
To convert a binary number you have to make use of the positional notation of the binary number. Here are the steps:

Step 1: Note down the increasing powers of 2 from left to right for each bit of information

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h8ftsup698opw04ruzwr.png)


Step 2: Write the corresponding binary number diget below the corresponding power of 2.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/94zjcwqtag5pnkcb8329.png)


Step 3: multiply the corresponding numbers together and then add the resulting product of each pair of numbers.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4kwc7k6dslkvl93ej4hf.png)


Have you just barely been able to understand the concept, and feel that the second you look away from your screen you might forget everything all together? Perfect! What a better time to explain another weird cluster of mumbo jumbo concepts!
The time has come for to learn how to do basic addition and subtraction. Addition and subtraction of binary numbers is almost the same as adding and subtracting base 10 numbers, but with a few new rules. 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1 but doing 1 + 1, we get 0 with 1 as a carry (e.g. 1 + 1 = 10). In the case of adding three 1's to each other you get 1 as a carry and then you add the 0 and the third 1 getting 11 (1 + 1 + 1 = 11). Subtraction rules are quite similar to addition rules, 1 - 0 = 1, 1 - 1 = 0, 0 - 0 = 0, however you can never do 0 - 1, since this would give us a negative number. In cases such as this you have to borrow a 1 from the next high order digit, which would result in 10 - 1. If you take a look at the rules of addition for binary numbers, you may notice that the addition of two 1's results in a 10, so if we subtract a 1 from a 10, we should result in a 1.
If you are reading this confused and discouraged, don't be. Here is a video that might help understand the concept better with examples: https://www.youtube.com/watch?v=C5EkxfNEMjE

You still with me? Still breathing? If your brain isn't already fried like KFC chicken at this point, then you are ready to dive into multiplication and division of binary numbers. Be happy to know that there aren't any new rules when it comes to multiplying and dividing binary numbers from base 10 numbers. Multiplying binary numbers is the same as multiplying 0's and 1's in base 10: 0 x 0 = 0, 1 x 0 = 0, 0 x 1 = 0, 1 x 1 = 1. If you are multiplying a long string 0's and 1's to another string of 0's and 1's then you proceed like you would when multiplying two base-10 numbers that aren't one digit: mupltiplying the lowest order digit to all the digits of the second number, then the next lowest order and so on. Division is also the same with binary numbers as with base 10, you perform the same multiplication and subtraction to long divide one binary number to another, but while doing this you need to remember that you can only multiple your binary number by either 0 or 1. Again, if you're having a hard time following along try viewing videos and reading some articles. Here is a link to a video about division of binary numbers: https://www.youtube.com/watch?v=VKemv9u40gc and a link to multiplication of binary numbers: https://www.youtube.com/watch?v=xHWKYFhhtJQ.

If you want to learn more about other number representation systems the next step would most likely be to learn about hexadecimal and octadecimal. Hexadecimal(base-16) is famously used to represent colors. It goes from 0-9 and then from A-F(10-16). There is also octadecimal(base-8) representation which uses numbers from 0-7 to represent infromation.
There you go, You have finished your geek training my pupil. Now you can go around spreading your nerd germs, infecting everyone with your know-it-all-ness till your heart's content. If you still don't have a tight grasp of anything that I've mentioned in this post, then do not fret. From one dork to another, it always takes some practice to be able to do it with no bumps on the road. 

Hakuna Matata!