Convert the number system from 2 to 10. Converting numbers from one number system to another online

To quickly convert numbers from the decimal number system to the binary system, you need to have a good knowledge of the numbers “2 to the power”. For example, 2 10 =1024, etc. This will allow you to solve some translation examples literally in seconds. One of these tasks is Problem A1 from the USE demo 2012. You can, of course, take a long and tedious time to divide a number by “2”. But it’s better to decide differently, saving valuable time on the exam.

The method is very simple. Its gist is this: If the number that needs to be converted from the decimal system is equal to the number "2 to the power", then this number in the binary system contains a number of zeros equal to the power. We add a “1” in front of these zeros.

  • Let's convert the number 2 from the decimal system. 2=2 1 . Therefore, in the binary system, a number contains 1 zero. We put “1” in front and get 10 2.
  • Let's convert 4 from the decimal system. 4=2 2 . Therefore, in the binary system, a number contains 2 zeros. We put “1” in front and get 100 2.
  • Let's convert 8 from the decimal system. 8=2 3 . Therefore, in the binary system, a number contains 3 zeros. We put “1” in front and get 1000 2.


Similarly for other numbers "2 to the power".

If the number that needs to be converted is less than the number “2 to the power” by 1, then in the binary system this number consists only of units, the number of which is equal to the power.

  • Let's convert 3 from the decimal system. 3=2 2 -1. Therefore, in the binary system, a number contains 2 ones. We get 11 2.
  • Let's convert 7 from the decimal system. 7=2 3 -1. Therefore, in the binary system, a number contains 3 ones. We get 111 2.

In the figure, the squares indicate the binary representation of the number, and the pink color on the left indicates the decimal representation.


The translation is similar for other numbers “2 to the power-1”.

It is clear that the translation of numbers from 0 to 8 can be done quickly or by division, or simply know by heart their representation in the binary system. I gave these examples so that you understand the principle this method and used it to translate more "impressive numbers", for example, to translate the numbers 127,128, 255, 256, 511, 512, etc.

You can come across such problems when you need to convert a number that is not equal to the number “2 to the power”, but close to it. It may be greater or less than 2 to the power. The difference between the translated number and the number "2 to the power" should be small. For example, up to 3. The representation of numbers from 0 to 3 in the binary system just needs to be known without translation.

If the number is greater than , then solve like this:

First we convert the number “2 to the power” into the binary system. And then we add to it the difference between the number “2 to the power” and the number being translated.

For example, let's convert 19 from the decimal system. It is greater than the number "2 to the power" by 3.

16=2 4 . 16 10 =10000 2 .

3 10 =11 2 .

19 10 =10000 2 +11 2 =10011 2 .

If the number is less than the number "2 to the power", then it is more convenient to use the number "2 to the power-1". We solve it like this:

First we convert the number “2 to the power-1” into the binary system. And then we subtract from it the difference between the number “2 to the power of 1” and the number being translated.

For example, let's convert 29 from the decimal system. It is greater than the number “2 to the power-1” by 2. 29=31-2.

31 10 =11111 2 .

2 10 =10 2 .

29 10 =11111 2 -10 2 =11101 2

If the difference between the number being translated and the number "2 to the power" is more than three, then you can break the number into its components, convert each part into the binary system and add.

For example, convert the number 528 from the decimal system. 528=512+16. We translate 512 and 16 separately.
512=2 9 . 512 10 =1000000000 2 .
16=2 4 . 16 10 =10000 2 .
Now let's add it in a column:

Converting numbers from one number system to another is an important part of machine arithmetic. Let's consider the basic rules of translation.

1. To convert a binary number to a decimal one, it is necessary to write it in the form of a polynomial, consisting of the products of the digits of the number and the corresponding power of 2, and calculate it according to the rules of decimal arithmetic:

When translating, it is convenient to use the table of powers of two:

Table 4. Powers of number 2

n (degree)

Example.

2. To convert an octal number to a decimal one, it is necessary to write it down as a polynomial consisting of the products of the digits of the number and the corresponding power of the number 8, and calculate it according to the rules of decimal arithmetic:

When translating, it is convenient to use the table of powers of eight:

Table 5. Powers of the number 8

n (degree)

Example. Convert the number to the decimal number system.

3. To convert a hexadecimal number to a decimal one, it is necessary to write it in the form of a polynomial, consisting of the products of the digits of the number and the corresponding power of the number 16, and calculate it according to the rules of decimal arithmetic:

When translating, it is convenient to use blitz of powers of number 16:

Table 6. Powers of the number 16

n (degree)

Example. Convert the number to the decimal number system.

4. To convert a decimal number to the binary system, it must be sequentially divided by 2 until a remainder less than or equal to 1 remains. A number in the binary system is written as a sequence of the last division result and the remainders from the division in reverse order.

Example. Convert the number to the binary number system.

5. To convert a decimal number to the octal system, it must be sequentially divided by 8 until a remainder less than or equal to 7 remains. A number in the octal system is written as a sequence of digits of the last division result and the remainder of the division in reverse order.

Example. Convert the number to the octal number system.

6. To convert a decimal number to the hexadecimal system, it must be sequentially divided by 16 until a remainder less than or equal to 15 remains. A number in the hexadecimal system is written as a sequence of digits of the last division result and the remainders from the division in reverse order.

Example. Convert the number to hexadecimal number system.

Methods for converting numbers from one number system to another.

Converting numbers from one positional number system to another: converting integers.

To convert an integer from one number system with base d1 to another with base d2, you must sequentially divide this number and the resulting quotients by base d2 of the new system until you get a quotient less than base d2. The last quotient is the highest digit of the number in new system numbers with base d2, and the numbers following it are remainders from division, written in the reverse order of their receipt. Perform arithmetic operations in the number system in which the number being translated is written.

Example 1. Convert the number 11(10) to the binary number system.

Answer: 11(10)=1011(2).

Example 2. Convert the number 122(10) to the octal number system.


Answer: 122(10)=172(8).

Example 3. Convert the number 500(10) to hexadecimal number system.


Answer: 500(10)=1F4(16).

Converting numbers from one positional number system to another: converting proper fractions.

To convert a proper fraction from a number system with base d1 to a system with base d2, it is necessary to sequentially multiply the original fraction and the fractional parts of the resulting products by the base of the new number system d2. The correct fraction of a number in the new number system with base d2 is formed in the form of integer parts of the resulting products, starting from the first.
If the translation results in a fraction in the form of an infinite or divergent series, the process can be completed when the required accuracy is achieved.

When translating mixed numbers, it is necessary to separately translate the integer and fractional parts into a new system according to the rules for translating integers and proper fractions, and then combine both results into one mixed number in the new number system.

Example 1. Convert the number 0.625(10) to the binary number system.


Answer: 0.625(10)=0.101(2).

Example 2. Convert the number 0.6(10) to the octal number system.


Answer: 0.6(10)=0.463(8).

Example 2. Convert the number 0.7(10) to hexadecimal number system.


Answer: 0.7(10)=0.B333(16).

Convert binary, octal and hexadecimal numbers to decimal number system.

To convert a number from the P-ary system to a decimal one, you must use the following expansion formula:
аnan-1…а1а0=аnPn+ аn-1Pn-1+…+ а1P+a0 .

Example 1. Convert the number 101.11(2) to the decimal number system.

Answer: 101.11(2)= 5.75(10) .

Example 2. Convert the number 57.24(8) to the decimal number system.

Answer: 57.24(8) = 47.3125(10) .

Example 3. Convert the number 7A,84(16) to the decimal number system.

Answer: 7A.84(16)= 122.515625(10) .


Converting octal and hexadecimal numbers to the binary number system and vice versa.

To convert a number from the octal number system to binary, each digit of this number must be written as a three-digit binary number (triad).

Example: write the number 16.24(8) in the binary number system.


Answer: 16.24(8)= 1110.0101(2) .

To convert a binary number back into the octal number system, you need to divide the original number into triads to the left and right of the decimal point and represent each group with a digit in the octal number system. Extreme incomplete triads are supplemented with zeros.

Example: write the number 1110.0101(2) in the octal number system.


Answer: 1110.0101(2)= 16.24(8) .

To convert a number from the hexadecimal number system to the binary system, you need to write each digit of this number as a four-digit binary number (tetrad).

Example: write the number 7A,7E(16) in the binary number system.


Answer: 7A,7E(16)= 1111010.0111111(2) .

Note: leading zeros on the left for integers and on the right for fractions are not written.

To convert a binary number back into the hexadecimal number system, you need to divide the original number into tetrads to the left and right of the decimal point and represent each group with a digit in the hexadecimal number system. Extreme incomplete triads are supplemented with zeros.

Example: write the number 1111010.0111111(2) in hexadecimal number system.

Those taking the Unified State Exam and more...

It is strange that in computer science lessons in schools they usually show students the most complex and inconvenient way to convert numbers from one system to another. This method consists of sequentially dividing the original number by the base and collecting the remainders from the division in reverse order.

For example, you need to convert the number 810 10 to binary:

We write the result in reverse order from bottom to top. It turns out 81010 = 11001010102

If you need to convert fairly large numbers into the binary system, then the division ladder takes on the size of a multi-story building. And how can you collect all the ones and zeros and not miss a single one?

The Unified State Exam program in computer science includes several tasks related to converting numbers from one system to another. Typically, this is a conversion between octal and hexadecimal systems and binary. These are sections A1, B11. But there are also problems with other number systems, such as in section B7.

To begin with, let us recall two tables that would be good to know by heart for those who choose computer science as their future profession.

Table of powers of number 2:

2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10
2 4 8 16 32 64 128 256 512 1024

It is easily obtained by multiplying the previous number by 2. So, if you do not remember all of these numbers, the rest are not difficult to obtain in your mind from those that you remember.

Table binary numbers from 0 to 15 with hexadecimal representation:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
0 1 2 3 4 5 6 7 8 9 A B C D E F

The missing values ​​are also easy to calculate by adding 1 to the known values.

Integer conversion

So, let's start by converting directly to the binary system. Let's take the same number 810 10. We need to decompose this number into terms equal to powers of two.

  1. We are looking for the power of two closest to 810 and not exceeding it. This is 2 9 = 512.
  2. Subtract 512 from 810, we get 298.
  3. Repeat steps 1 and 2 until there are no 1s or 0s left.
  4. We got it like this: 810 = 512 + 256 + 32 + 8 + 2 = 2 9 + 2 8 + 2 5 + 2 3 + 2 1.
Then there are two methods, you can use any of them. How easy it is to see that in any number system its base is always 10. The square of the base will always be 100, the cube 1000. That is, the degree of the base of the number system is 1 (one), and there are as many zeros behind it as the degree is.

Method 1: Arrange 1 according to the digits of the indicators of the terms. In our example, these are 9, 8, 5, 3 and 1. The remaining places will contain zeros. So, we got the binary representation of the number 810 10 = 1100101010 2. Units are placed in 9th, 8th, 5th, 3rd and 1st places, counting from right to left from zero.

Method 2: Let's write the terms as powers of two under each other, starting with the largest.

810 =

Now let's add these steps together, like folding a fan: 1100101010.

That's all. At the same time, the problem “how many units are in the binary notation of the number 810?” is also simply solved.

The answer is as many as there are terms (powers of two) in this representation. 810 has 5 of them.

Now the example is simpler.

Let's convert the number 63 to the 5-ary number system. The closest power of 5 to 63 is 25 (square 5). A cube (125) will already be a lot. That is, 63 lies between the square of 5 and the cube. Then we will select the coefficient for 5 2. This is 2.

We get 63 10 = 50 + 13 = 50 + 10 + 3 = 2 * 5 2 + 2 * 5 + 3 = 223 5.

And, finally, very easy translations between 8 and hexadecimal systems. Since their base is a power of two, the translation is done automatically, simply by replacing the numbers with their binary representation. For the octal system, each digit is replaced by three binary digits, and for the hexadecimal system, four. In this case, all leading zeros are required, except for the most significant digit.

Let's convert the number 547 8 to binary.

547 8 = 101 100 111
5 4 7

One more, for example 7D6A 16.

7D6A 16 = (0)111 1101 0110 1010
7 D 6 A

Let's convert the number 7368 to the hexadecimal system. First, write the numbers in triplets, and then divide them into quadruples from the end: 736 8 = 111 011 110 = 1 1101 1110 = 1DE 16. Let's convert the number C25 16 to the octal system. First, we write the numbers in fours, and then divide them into threes from the end: C25 16 = 1100 0010 0101 = 110 000 100 101 = 6045 8. Now let's look at converting back to decimal. It is not difficult, the main thing is not to make mistakes in the calculations. We expand the number into a polynomial with powers of the base and coefficients for them. Then we multiply and add everything. E68 16 = 14 * 16 2 + 6 * 16 + 8 = 3688. 732 8 = 7 * 8 2 + 3*8 + 2 = 474 .

Converting Negative Numbers

Here you need to take into account that the number will be presented in two's complement code. To convert a number into additional code, you need to know the final size of the number, that is, what we want to fit it into - in a byte, in two bytes, in four. The most significant digit of a number means the sign. If there is 0, then the number is positive, if 1, then it is negative. On the left, the number is supplemented with a sign digit. We do not consider unsigned numbers; they are always positive, and the most significant bit in them is used as information.

To convert a negative number to binary's complement, you need to convert a positive number to binary, then change the zeros to ones and the ones to zeros. Then add 1 to the result.

So, let's convert the number -79 to the binary system. The number will take us one byte.

We convert 79 to the binary system, 79 = 1001111. We add zeros on the left to the size of the byte, 8 bits, we get 01001111. We change 1 to 0 and 0 to 1. We get 10110000. We add 1 to the result, we get the answer 10110001. Along the way, we answer the Unified State Exam question “how many units are in the binary representation of the number -79?” The answer is 4.

Adding 1 to the inverse of a number eliminates the difference between the representations +0 = 00000000 and -0 = 11111111. In two's complement code they will be written the same as 00000000.

Converting fractional numbers

Fractional numbers are converted in the reverse way of dividing whole numbers by the base, which we looked at at the very beginning. That is, using sequential multiplication by a new base with the collection of whole parts. The integer parts obtained during multiplication are collected, but do not participate in the following operations. Only fractions are multiplied. If the original number is greater than 1, then the integer and fractional parts are translated separately and then glued together.

Let's convert the number 0.6752 to the binary system.

0 ,6752
*2
1 ,3504
*2
0 ,7008
*2
1 ,4016
*2
0 ,8032
*2
1 ,6064
*2
1 ,2128

The process can be continued for a long time until we get all the zeros in the fractional part or the required accuracy is achieved. Let's stop at the 6th sign for now.

It turns out 0.6752 = 0.101011.

If the number was 5.6752, then in binary it will be 101.101011.

To convert numbers from decimal s/s to any other, you need to divide decimal number on the basis of the system into which they are transferred, while retaining the remainders from each division. The result is generated from right to left. The division continues until the result of the division is less than the divisor.

The calculator converts numbers from one number system to any other. It can convert numbers from binary to decimal or decimal to hexadecimal, showing the detailed solution progress. You can easily convert a number from ternary to quinary or even from septenary to seventeenth. The calculator can convert numbers from any number system to any other.

Online calculator: Convert numbers from one number system to any other online

Input data

Enter the number:


Its number system
Binary
Trinity
Octal
Decimal
Hexadecimal
Binary Decimal
Other

By triads
By notebooks

Which? (number)


Convert to
Binary
Trinity
Octal
Decimal
Hexadecimal
Binary Decimal
Another

Which? (number)

Methods for converting numbers from one number system to another

To the program Unified State Exam in Computer Science includes several tasks related to converting numbers from one system to another. Typically, this is a conversion between octal and hexadecimal systems and binary. These are the sections A1, AT 11. But there are also problems with other number systems, such as in the section B7.

To begin with, let us recall two tables that would be good to know by heart for those who choose computer science as their future profession.

Table of powers of number 2:

2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 2 10
2 4 8 16 32 64 128 256 512 1024

It is easily obtained by multiplying the previous number by 2. So, if you don’t remember all of these numbers, it’s not difficult to get the rest in your mind from those that you remember.

Table of binary numbers from 0 to 15 with hexadecimal representation:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
0 1 2 3 4 5 6 7 8 9 A B C D E F

The missing values ​​are also easy to calculate by adding 1 to the known values.

Arithmetic operations in the binary number system

When two numbers equal to 1 are added, the result in this digit is 0, and the 1 is transferred to the highest digit.

Integer conversion

So, let's start by converting directly to the binary system. Let's take the same number 810 10. We need to decompose this number into terms equal to powers of two.
  1. We are looking for the power of two closest to 810 and not exceeding it. This is 2 9 = 512.
  2. Subtract 512 from 810, we get 298.
  3. Repeat steps 1 and 2 until there are no 1s or 0s left.
  4. We got it like this: 810 = 512 + 256 + 32 + 8 + 2 = 2 9 + 2 8 + 2 5 + 2 3 + 2 1 .
Then there are two methods, you can use any of them. How easy it is to see that in any number system its base is always 10. The square of the base will always be 100, the cube 1000. That is, the degree of the base of the number system is 1 (one), and behind it there are as many zeros as the degree.

Method 1: Arrange 1 according to the digits of the indicators of the terms. In our example, these are 9, 8, 5, 3 and 1. The remaining places will contain zeros. So, we got the binary representation of the number 810 10 = 1100101010 2. Units are placed in 9th, 8th, 5th, 3rd and 1st places, counting from right to left from zero.

Method 2: Let's write the terms as powers of two under each other, starting with the largest.

810 =

Now let's add these steps together, like folding a fan: 1100101010.

That's all. At the same time, the problem “how many units are in the binary notation of the number 810?” is also simply solved.

The answer is as many as there are terms (powers of two) in this representation. 810 has 5 of them.

Now the example is simpler.

Let's convert the number 63 to the 5-ary number system. The closest power of 5 to 63 is 25 (square 5). A cube (125) will already be a lot. That is, 63 lies between the square of 5 and the cube. Then we will select the coefficient for 5 2. This is 2.

We get 63 10 = 50 + 13 = 50 + 10 + 3 = 2 * 5 2 + 2 * 5 + 3 = 223 5.

And, finally, very easy translations between 8 and hexadecimal systems. Since their base is a power of two, the translation is done automatically, simply by replacing the numbers with their binary representation. For the octal system, each digit is replaced by three binary digits, and for the hexadecimal system, four. In this case, all leading zeros are required, except for the most significant digit.

Let's convert the number 547 8 to binary.

547 8 = 101 100 111
5 4 7

One more, for example 7D6A 16.

7D6A 16 = (0)111 1101 0110 1010
7 D 6 A

Let's convert the number 7368 to the hexadecimal system. First, write the numbers in triplets, and then divide them into quadruples from the end: 736 8 = 111 011 110 = 1 1101 1110 = 1DE 16. Let's convert the number C25 16 to the octal system. First, we write the numbers in fours, and then divide them into threes from the end: C25 16 = 1100 0010 0101 = 110 000 100 101 = 6045 8. Now let's look at converting back to decimal. It is not difficult, the main thing is not to make mistakes in the calculations. We expand the number into a polynomial with powers of the base and coefficients for them. Then we multiply and add everything. E68 16 = 14 * 16 2 + 6 * 16 + 8 = 3688. 732 8 = 7 * 8 2 + 3*8 + 2 = 474 .

Converting Negative Numbers

Here you need to take into account that the number will be presented in two's complement code. To convert a number into additional code, you need to know the final size of the number, that is, what we want to fit it into - in a byte, in two bytes, in four. The most significant digit of a number means the sign. If there is 0, then the number is positive, if 1, then it is negative. On the left, the number is supplemented with a sign digit. Unsigned ( unsigned ) we do not consider numbers, they are always positive, and the most significant digit in them is used as information.

To convert a negative number to binary's complement, you need to convert a positive number to binary, then change the zeros to ones and the ones to zeros. Then add 1 to the result.

So, let's convert the number -79 to the binary system. The number will take us one byte.

Converting 79 to binary, 79 = 1001111. Let's add zeros on the left to a byte size of 8 bits, we get 01001111. We change 1 to 0 and 0 to 1. We get 10110000. We add 1 to the result, we get the answer 10110001.

Along the way, we answer the Unified State Exam question “ how many units are there in the binary representation of the number -79?».

The answer is 4.

Adding 1 to the inverse of a number eliminates the difference between the representations +0 = 00000000 and -0 = 11111111. In additional code they will be written the same way: 00000000.

Converting fractional numbers

Fractional numbers are converted in the reverse way of dividing whole numbers by the base, which we looked at at the very beginning. That is, using sequential multiplication by a new base with the collection of whole parts. The integer parts obtained during multiplication are collected, but do not participate in the following operations. Only fractions are multiplied. If the original number is greater than 1, then the integer and fractional parts are translated separately and then glued together.

Let's convert the number 0.6752 to the binary system.

0 ,6752
*2
1 ,3504
*2
0 ,7008
*2
1 ,4016
*2
0 ,8032
*2
1 ,6064
*2
1 ,2128

The process can be continued for a long time until we get all the zeros in the fractional part or the required accuracy is achieved. Let's stop at the 6th sign for now.

It turns out 0.6752 = 0.101011.

If the number was 5.6752, then in binary it will be 101.101011.

Javascript is disabled in your browser.
To perform calculations, you must enable ActiveX controls!