▷ Binary, decimal, octal and hexadecimal system what it is and how it works
Table of contents:
- How to perform numbering system conversions
- Numbering systems
- Decimal system
- Binary system
- Octal system
- Hexadecimal system
- Conversion between binary and decimal system
- Convert number from binary to decimal
- Convert decimal number to binary
- Conversion fractional decimal number to binary
- Conversion fractional binary number to decimal
- Conversion between octal system and binary system
- Convert number from binary to octal
- Convert octal number to binary
- Conversion between octal system and decimal system
- Convert decimal number to octal
- Convert octal number to decimal
- Conversion between hexadecimal system and decimal system
- Convert decimal number to hexadecimal
- Convert number from hexadecimal to decimal
If you are a student of Computer Science, electronics or any branch of engineering, one of the things you should know is to perform numbering system conversions. In computing, the numbering systems used are different from what we traditionally know, as is our decimal system. This is why, very possibly, if we dedicate ourselves to the field of both computing, programming and similar technology, we will need to know the most used systems and how to know how to convert from one system to another.
Index of contents
How to perform numbering system conversions
It is especially useful to know the Decimal to Binary conversion system and vice versa, since it is the numbering system with which the components of a computer work directly. But it is also very useful to know the hexadecimal system, since it is used for example to represent the color codes, keys and a large number of codes from our team.
Numbering systems
A numbering system consists of the representation of a set of symbols and rules that allow us to build the numbers that are valid. In other words, it consists of using a series of bounded symbols with which it will be possible to form other numerical values without any limit.
Without going too far into mathematical terms of definitions, the systems most used by humans and machines will be the following:
Decimal system
It is a positional numbering system in which quantities are represented by the arithmetic base of the number ten.
As the base is number ten, we will have the ability to build all the figures using ten numbers that are the ones we all know. 0, 1, 2 3, 4, 5, 6, 7, 8 and 9. These numbers will be used to represent the position of the powers of 10 in the formation of any number.
So, we could represent a number in the following way in this numbering system:
We see that a decimal number is the sum of each value by the base 10 raised to the position-1 that each term occupies. We will keep this in mind for conversions in other numbering systems.
Binary system
The binary system is a numbering system in which the arithmetic base 2 is used. This system is the one used by computers and digital systems internally to carry out absolutely all processes.
This numbering system is only represented by two digits, 0 and 1, which is why it is based on 2 (two digits). With it all value chains will be built.
Octal system
As with the previous explanations, we can already imagine what this is about the octal system. The Octal system is the numbering system in which the arithmetic base 8 is used, that is, we will have 8 different digits to represent all the numbers. These will be: 0, 1, 2, 3, 4, 5, 6 and 7.
Hexadecimal system
Following the previous definitions, the decimal numbering system is a positional numbering system based on the number 16. At this point we will ask ourselves, how are we going to get 16 different numbers, if for example 10 is the combination of two numbers different?
Well, very simple, we invented them, not us, but those who invented the system in question. The numbers that we will have here will be: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F. this makes a total of 16 different terms. If you have ever set the numeric code of a color it has this type of numbering, and this is why you will see how white, for example, is represented as the value FFFFFF. We will see later what this means.
Conversion between binary and decimal system
As it is the most basic and easy to understand, we will start by converting between these two numbering systems.
Convert number from binary to decimal
As we saw in the first section, we represent a decimal number as the sum of the values multiplied by the power of 10 to the position-1 it occupies. If we apply this to any binary number, with its corresponding base, we will have the following:
one | 0 | 0 | one | one |
0 |
1 · 2 5 | 1 · 2 4 | 1 · 2 3 | 1 · 2 2 | 1 · 2 1 |
1 · 2 0 |
But of course, if we did the procedure as in the decimal system, we would obtain values other than 0 and 1, which are the ones that we can only represent in this numbering system.
But precisely this is going to be very useful to perform the conversion to the decimal system. Let's calculate the result of each value in its box:
one | 0 | 0 | one | one |
0 |
1 · 2 5 = 32 |
1 · 2 4 = 0 | 1 · 2 3 = 0 | 1 · 2 2 = 4 | 1 · 2 1 = 2 |
1 · 2 0 = 0 |
Well, if we make the sum of these values resulting from each cell, we will obtain the decimal equivalent value of the binary value.
The decimal value of 100110 is 38
We have only had to multiply the digit (0 or 1) by its base (2) raised to position-1 it occupies in the figure. We add the values and we will have the number in decimal.
If you have not been convinced, we will now carry out the opposite process:
Convert decimal number to binary
If before we did a multiplication of the numbers and a sum to determine the value in decimal, now what we will have to do is divide the decimal number by the base of the system we want to convert it to, in this case 2.
We will carry out this procedure until it is no longer possible to carry out any further division. Let's see the example of how it would be done.
Number |
38 | 19 | 9 | 4 | two | one |
Division |
÷ 2 = 19 |
÷ 2 = 9 | ÷ 2 = 4 | ÷ 2 = 2 | ÷ 2 = 1 |
- |
Rest | 0 | one | one | 0 | 0 |
one |
This is the result of making the successive divisions to a minimum. You may have already realized how this works. If we now take the remainders of each division, and invert its position, we will obtain the binary value of the decimal number. That is, started from where we ended the division backwards:
So we have the following result: 100110
As we can see, we have managed to have exactly the same number as at the beginning of the section.
Conversion fractional decimal number to binary
As we well know, there are not only whole decimal numbers, but we can also find real numbers (fractions). And as a numbering system, it should be possible to convert a number from the decimal system to the binary system. We see how to do it. Let's take the number 38, 375 as an example
What we must do is separate each of the parts. We already know how to calculate the integer part, so we will go directly to the decimal part.
The procedure will be as follows: we must take the decimal part and multiply it by the base of the system, that is, 2. The result of the multiplication we must multiply it again until we get a fractional part of 0. If when doing the multiplication a factional number appears with an integer part, we will only have to take the fraction for the next multiplication. Let's look at the example to understand it better.
Number |
0.375 | 0.75 | 0.50 |
Multiplication | * 2 = 0.75 | * 2 = 1.50 |
* 2 = 1.00 |
Whole part | 0 | one |
one |
As we can see, we are taking the decimal part and multiplying it again until we reach 1.00 where the result will always be 0.
The result of 38, 375 in binary will then be 100 110, 011
But what happens when we can never reach a result of 1.00 in the process? Let's see the example with 38, 45
Number |
0.45 | 0.90 | 0.80 | 0.60 | 0.20 | 0.40 | 0.80 |
Multiplication | * 2 = 0.90 | * 2 = 1.80 | * 2 = 1.60 | * 2 = 1.20 | * 2 = 0.40 | * 2 = 0.80 | * 2 = 1.60 |
Whole part | 0 | one | one | one | 0 | 0 |
one |
As we can see , from 0.80 the process becomes periodic, that is, we will never finish the procedure because the numbers from 0.8 to 0.4 will always appear. Then our result will be an approximation of the decimal number, the farther we go, the greater accuracy we will obtain.
So: 38.45 = 100 110, 01110011001 1001 …
Let's see how to do the reverse process
Conversion fractional binary number to decimal
This process will be carried out in the same way as the normal base change, except that from the comma the powers will be negative. Let's just take the integer part of the previous binary number:
0 | one | one | one | 0 | 0 |
one |
… |
0 · 2 -1 = 0 | 1 · 2 -2 = 0.25 | 1 · 2 -3 = 0.125 | 1 · 2 -4 = 0.0625 | 1 · 2 -5 = 0 | 1 · 2 -6 = 0 | 1 · 2 -7 = 0.0078125 | … |
If we add the results we will obtain:
0.25 + 0.125 + 0.0625 + 0.0078125 = 0.4453
If we continued to carry out operations we would get closer and closer to the exact value of 38.45
Conversion between octal system and binary system
Now we will proceed to see how to perform the conversion between two systems that are not the decimal, for this we will take the octal system and the binary system and we will do the same procedure as in the previous sections.
Convert number from binary to octal
The conversion between both numbering systems is very simple because the base of the octal system is the same as in the binary system but raised to the power of 3, 2 3 = 8. So based on this, what we are going to do is group the binary terms into groups of three starting from the right to the left and directly convert to a decimal number. Let's see the example with the number 100110:
one | 0 | 0 | one | one | 0 |
100 | 110 | ||||
0 · 2 2 = 4 | 0 · 2 1 = 0 | 1 · 2 0 = 0 | 1 · 2 2 = 4 | 1 · 2 1 = 2 | 0 · 2 0 = 0 |
4 | 6 |
We group every three digits and do the conversion to decimal. The end result will be that 100110 = 46
But what if we don't have perfect groups of 3? For example 1001101, we have two groups of 3 and one of 1, let's see how to proceed:
0 | 0 | one | 0 | 0 | one | one | 0 | one |
001 | 100 | 110 | ||||||
0 · 2 2 = 0 | 0 · 2 1 = 0 | 1 · 2 0 = 1 | 0 · 2 2 = 0 | 0 · 2 1 = 0 | 1 · 2 0 = 1 | 1 · 2 2 = 4 | 1 · 2 1 = 0 | 1 · 2 0 = 1 |
one | one | 5 |
Following the procedure, we take the groups from the right of the term and when we reach the end we fill with as many zeros as necessary. In this case, we have needed two to complete the last group. So 1001101 = 115
Convert octal number to binary
Well, the procedure is as simple as doing the opposite, that is, going from binary to decimal in groups of 3. Let's see it with the number 115
Value | one | one | 5 | ||||||
Division | ÷ 2 = 0 | 0 | 0 | ÷ 2 = 0 | 0 | 0 | ÷ 2 = 2 | ÷ 2 = 1 | - |
Rest | one | 0 | 0 | one | 0 | 0 | one | 0 | one |
Group | 001 | 001 | 101 |
In this way we see that 115 = 001001101 or what is the same 115 = 1001101
Conversion between octal system and decimal system
Now we are going to see how to perform the procedure of going from the octal number system to the decimal and vice versa. We will see that the procedure is exactly the same as in the case of the decimal and binary system, only we must change the base to 8 instead of 2.
We will carry out the procedures directly with terms with a fractional part.
Convert decimal number to octal
Following the procedure of the decimal-binary method we will carry it out with the example of 238.32:
Whole part. We divide by the base, which is 8:
Number | 238 | 29 | 3 |
Division | ÷ 8 = 29 | ÷ 8 = 3 | - |
Rest | 6 | 5 | 3 |
Decimal part, we multiply by the base, which is 8:
Number | 0.32 | 0.56 | 0.48 | 0.84 | 0.72 | … |
Multiplication | * 8 = 2.56 | * 8 = 4.48 | * 8 = 3.84 | * 8 = 6.72 | * 8 = 5.76 | … |
Whole part | two | 4 | 3 | 6 | 5 | … |
The result obtained is as follows: 238.32 = 356.24365…
Convert octal number to decimal
Well then, let's do the opposite process. Let's pass the octal number 356, 243 to decimal:
3 | 5 | 6 | , | two | 4 | 3 |
3 · 8 2 = 192 | 5 · 8 1 = 40 | 6 · 2 0 = 6 | 2 · 8 -1 = 0.25 | 4 · 8 -2 = 0.0625 | 3 · 8 -3 = 0.005893 |
The result is: 192 + 40 + 6, 0.25 + 0.0625 + 0.005893 = 238.318
Conversion between hexadecimal system and decimal system
We then finish with the conversion process between the hexadecimal numbering system and the decimal system.
Convert decimal number to hexadecimal
Following the procedure of the decimal-binary and decimal-octal method we will carry it out with the example of 238.32:
Whole part. We divide by the base, which is 16:
Number | 238 | 14 |
Division | ÷ 16 = 14 | - |
Rest | AND | AND |
Decimal part, we multiply by the base, which is 16:
Number | 0.32 | 0.12 | 0.92 | 0.72 | 0.52 | … |
Multiplication | * 16 = 5.12 | * 16 = 1.92 | * 16 = 14.72 | * 16 = 11.52 | * 16 = 8.32 | … |
Whole part | 5 | one | AND | B | 8 | … |
The result obtained is as follows: 238.32 = EE, 51EB8…
Convert number from hexadecimal to decimal
Well then, let's do the opposite process. Let's pass the hexadecimal number EE, 51E to decimal:
AND | AND | , | 5 | one | AND |
E16 1 = 224 | E · 16 0 = 14 | 5 · 16 -1 = 0.3125 | 1 · 16 -2 = 0.003906 | E16 -3 = 0.00341 |
The result is: 224 + 14, 0.3125 + 0.003906 + 0.00341 = 238.3198…
Well these are the main ways to change the base from one numbering system to another. The system is applicable to a system in any base and the decimal system, although these are the most used in the field of computing.
You may also like:
If you have any questions, leave them in the comments. We will try to help you.
Microsoft works on a streaming game system
Microsoft works on a streaming system that would allow playing games on their Xbox from mobile devices or the browser
Huawei works on its own mobile operating system
Huawei works on its own mobile operating system as a future alternative to Android so as not to depend on Google in the development of its terminals.
Facebook works on a facial recognition system
Facebook works on a facial recognition system. Find out more about the new facial recognition system of the social network.