Maths for dummies: the binary code

in #programming7 years ago

To understand what the binary code is, before we have to know what the binary numbers are.

The binary numbers are all those numbers formed by 0's and 1's, ie: 101, 11111, 1000011, etc etc etc.
The numbers that are used day by day to count, in the calendar ... that is, the normal numbers, are decimal numbers, that is, numbers composed of digits 0 through 9: 141341, 92921, 4552. These are the numbers Which we all know.

But what's the use of binary numbers? Many people will know that machines use binary coding to function, to communicate, to send messages, etc. This is because the machines are made up of electronic, magnetic, electronic components that can be on or off.

Do you know where I'm going? When the component is on, it corresponds to a 1, and when it is off, it corresponds to 0. Sounds easy, does not it? It is not so much. With these two numbers, the machines need to understand everything: numbers, colors, texts, positions, etc etc etc.

This is possible because every color, every letter, every number, has its representation in decimal number and then that decimal number, can be converted to binary number.

Now, to understand how the binary system works, and how to go from a decimal number to a binary number and let our computer know what we mean, we must understand how our decimal system works.

Take the number 524. At school we were taught that is 4 units, 2 in the tens and 5 in the hundreds. This means that 4 is 4, 2 is 20, and 5 is 500. The three numbers together in that order form 524.

But why 4 is 4, 2 is 20 and 5 is 500? That's due to the right-to-left position that has the digit in the number. That is, as it is a decimal system, each column or each position, is worth 10 times more than the column or position to its right.

                    10000       1000      100      10      1
                                           5        2      4

Now if we multiply the value of each digit by the value of each column and add the columns, we would give the number 524.

              4 x 1 + 2 x 10 + 5 x 100  =   4 + 20 + 500  =  524

Well, now that we understand this, the binary system is exactly the same, only instead of columns worth 10 times the value of its right, it is just 2.

      512        256      128      64       32      16      8      4      2       1
        1         0        0       0        0       0       1      1      0       0

If we now multiply each binary digit by the value of its column and then we add the columns, we will get 524 and we will know that the number 1000001100 corresponds to the number 524 in binary.

1 x 512 + 0 x 256 + 0 x 128 + 0 x 64 + 0 x 32 + 0 x 16 + 1 x 8 + 1 x 4 + 0 x 2 + 0 x 1=
512 + 0 + 0 + 0 + 0 + 0 + 8 + 4 + 0 + 0  =  524 

Now that we know this, we can put with binary numbers anything that comes to mind. The only bad thing is that they occupy more, but it is the only way to make our computers know what we mean :)

Sort:  

GREAT POST :D :D :D

Follow and vote @cryptonnn .. I will follow you back , and vote :)