Everyone knows how to count in base 10 (decimal system). But how does it work?
With these 10 digits, we can count effortlessly from 0 to 9. But how do we do it afterwards? The problem arises when the units rank is full. Well, when it's full, we change rank, and move to the tens rank, then hundreds, thousands, etc.
Thus, we count up to 9, then the rank is full, so we add one unit to the tens rank, and start over... until we fill the tens rank. We then start filling the hundreds, etc.
Thus, for example for the value 29, we can no longer increment the units rank, so we increment the higher rank (tens), and reset the lower ranks (units) to 0.
We are here in base 10, so:
A computer is composed of circuits and electronic components. The simplest way, to count, is therefore to use a base 2 system that can translate two states:
Presence of current: state 1 Absence of current: state 0
If we want to apply the same logic seen previously to base 2, we just need to transpose these same rules to a base value set composed of two elements: 0 and 1.
The method for converting a number from base 10 to base 2 is simple:
In daily life, with our 10 fingers, base 10 is perfectly suited. In computing, closest to the machine, everything is coded in base 2.
But in computing, since everything is based on binary, it's easier to encode information in a base that would be a multiple of 2, so we very often use base 16.
| Name | Base | Units |
|---|---|---|
| decimal | 10 | 0 1 2 3 4 5 6 7 8 9 |
| binary | 2 | 0 1 |
| hexadecimal | 16 | 0 1 2 3 4 5 6 7 8 9 A B C D E F |
The method for converting a number from base 2 to base 16 is simple:
For conversion in the other direction, it's just as simple:
We use the following correspondence table:
| Binary (base 2) | Decimal (base 10) | Hexadecimal (base 16) |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | 1 |
| 0010 | 2 | 2 |
| 0011 | 3 | 3 |
| 0100 | 4 | 4 |
| 0101 | 5 | 5 |
| 0110 | 6 | 6 |
| 0111 | 7 | 7 |
| 1000 | 8 | 8 |
| 1001 | 9 | 9 |
| 1010 | 10 | A |
| 1011 | 11 | B |
| 1100 | 12 | C |
| 1101 | 13 | D |
| 1110 | 14 | E |
| 1111 | 15 | F |