# Binary Code

The Binary Code

To understand informatics, the first thing to do is to learn and to understand the language on which it's based.

There are a lot of pages, available in internet, about this argument, but I want to use a different way to explain it, in a more simple language, so that (I hope) a lot of people could understand this "strange way to count".

Everyone can count in the usual way, the decimal one, but WHY do we use that method ?

I believe I can say that human beings, in every time, in every place, have found very simple to count objects using something at FINGERtips !!

Let's say, the number 25, we all know it represents 2 tens and 5 units, this means that you have to raise up twice ALL the fingers of both hands, then five fingers more, in order to count 25 things.

Every new position in a number, from right to left, tells us how many times you have to count ALL the available ciphers for the nearest right position. This is the keyword, to understand: "all the available ciphers".

In decimal system, obviously, we have ten digits available, these are: 1,2,3,4,5,6,7,8,9,0 (I put "zero" at bottom to make it all clear).

Then, we say that 10 is the base of the numbering (then, it's also the base for exponentiation, we'll see them in a moment)

So, if we say 15, we are saying that we count every "finger" (digit) ONE time, then again 5 digits (the grandtotal, as we all know, is [1 x 10 + 5 x 1] or, same thing, [1 ten + 5 units]).

Let's repeat the reasoning, with a greater number, we choose 1296.

Meanwhile, see it decomposed:

 position 4° 3° 2° 1° digit 1 2 9 6 meaning thousands hundreds tens units Power of 10 103 102 101 100

This table is a "classical" one, bou now I'd like to represent that number using all people that we need for "count" it.

Here are 4 friends: Tony, Harry, Terence and Uma.

Uma's hands count from 1 to 1296, while she does this, other friends keep trace of the counting, in this way:
Terence raise a finger every time that Uma ends a serie of 10, and she has begun again.
[When Uma raises all fingers, it means she counted 10, so she immediately lowers all fingers, and Terence raises one finger, keep in mind: NOBODY stays with all fingers up]
Harry raises a finger every time that Terence ends a serie of 10 and he has begun again.
Tony raises a finger every time that Harry ends a serie of 10 and he has begun again.

Obviously, the final result will be this one:

 Tony Harry Terence Uma 1 finger up 2 fingers up 9 fingers up 6 fingers up

Well, what if these friends have only TWO fingers at all?

Here's what wuold happen, for example, to count the number 25:

[Remember the fact that, when we count in this way, who is REALLY counting all items is the rightmost person {i.e. Uma}, and when a friend raises all fingers happens this: he lowers all fingers and the nearest left friend raises one more finger to signal that his right friend has ended a serie and begun again]

Our Uma has ONLY two fingers, how may times does she raise all of them?
Obviously 25 divided by 2 that is 12, with the remainder of 1, it means that Uma will stay with 1 finger up

So, Terence must count how many times Uma raised all fingers, that is 12, but he has only two fingers too, then he'll raise them 12 divided by 2, that's equal to 6 with remainder of 0, Terence will stay with NO fingers up.

Again, Harry must count how many times Terence raised all his fingers, that is 6, then Harry will raise his fingers 6 divided by 2 that's equal to 3 with NO remainder

Tony should count the 3 times Harry's raised his fingers, so: he'll raise all his fingers once and will remain with 1 finger up.

We need another friend, Paul: he counts how many times Tony has "lowered all his fingers" (that means how many times he has done a complete counting), that is only once. Paul will stay with one finger up.

 Paul Tony Harry Terence Uma friends 1 finger up 1 finger up NO fingers up NO fingers up 1 finger up fingers 1 1 0 0 1 Binary cyphers 24 23 22 21 20 power of 2 1 x 24 1 x 23 0 x 22 0 x 21 1 x 20 Sum=25

The number 25, in binary code, is 11001.
The base of the numbering is 2

Exactly as in the case of decimal numbering, the meaning of the number 11001 is what follows (we begin from the rightmost position, the 1st position, that is the position of the UNITS, i.e. the POWER ZERO of the base choosen for counting):

1 x 20 = 1 x 1 = 1
0 x 21 = 0 x 2 = 0
0 x 22 = 0 x 4 = 0
1 x 23 = 1 x 8 = 8
1 x 24 = 1 x 16 = 16

and... 1+8+16= 25 !!

Binary numbering has only two cyphers to form all numbers, these are "0" and "1".

Let's see the method to convert:

To transform the number 324 from base 10 (decimal) to base 2 (binary) we go through a sequence of divisions by the base:

 step number divided by equals with remainder of 1 324 2 162 0 (this is the rightmost cypher of the result) 2 162 2 81 0 3 81 2 40 1 4 40 2 20 0 5 20 2 10 0 6 10 2 5 0 7 5 2 2 1 8 2 2 1 0 9 1 2 0 1

We have found that 324 base 10 equals to 101000100 base 2 !!

This method is good for every base.

If we have base 16 (HEXADECIMAL code, or numbering), we'd use the same method, as seen before, but, having only 10 cyphers, we'd use 6 MORE SYMBOLS for ths new way of numbering: by convention capital letters A,B,C,D,E,F are used.

Then, an A in hexadecimal is 10, a B is 11... and so on up to F that is 15. And all goes well, because dividing by 16, I can get a remainder that goes from 0 to 15.

If I was useful to you, please, consider a
small donation towards server costs