Functions for the translation of the number systems. Number system. Transfer from one system to another. Translation of the fractional part of the number from the decimal number system to another number system

Rules for translation numbers from one number system to another

Since the same number can be recorded in various numbering systems (for example,), then the question arises about the transfer of the representation of the number from one system to another. The rules for translation for integers and fractional numbers are different.

To transfer numbers from any number system to decimal, you can use the formula (1).

Example. Translate into a decimal number system number

Decision:

Transfer of integers from one number system to another

1. Share the specified number on a new base recorded in the form of a number with an old base before receiving the balance.

2. The received private one should again divide on a new base, and this process must be repeated until the private becomes less than the divider.

3. The obtained remnants from division and the last private are written in the reverse order obtained during the division.

Decision:

Translation of fractional numbers from one number system to another

Multiply a given number to a new base recorded in the form of a number with an old base. With each multiplying, the whole part of the work is taken in the form of another digit of the corresponding discharge, and the remaining fractional part Accepted for a new multiple. The number of multiplications determines the discharge of the result obtained.

Example. Translate a number into a binary, octal, hexadecimal number system.

Decision:

Solution: We translate separately the whole and fractional part of the number into the binary number system.

.

Connecting the whole and fractional parts, we get

Since the binary, octal and hexadecimal surfaces are associated with each other through degree 2, then the transformation between them can be performed more simple way.

1. To transfer from a hexadecimal (octic) system of the number to a binary enough binary code to write hexadecimal (octal) codes of numbers with tetrads (triads).

2. Reverse transfer from binary code is made in reverse order: The binary number is broken down to the left and right from the comma on the notebooks for the subsequent record of the numbers in hexadecimal representation and the triads - to record their values \u200b\u200bof the octal numerals.

3. When switching from an octal number system to hexadecimal and back is used auxiliary, binary number code.

Example. Translate a number in an octal, hexadecimal number system.

Decision:

Example. Translate a number into a binary number system.

Decision:

We pass the exam and not only ...

It is strange that in schools in the lessons of informatics usually show students the most difficult and inconvenient way of transferring numbers from one system to another. This method consists in a consistent division of the initial number on the basis and collecting residues from dividing in the reverse order.

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

The result is written in the reverse order from the bottom up. It turns out 81010 \u003d 11001010102

If you need to translate in a binary system quite large numbers, the division staircase acquires the size of a multi-storey building. And how to collect all the units with zeros and not to miss any one?

The program of the EGE on computer science includes several tasks associated with the transfer of numbers from one system to another. As a rule, this is a transformation between 8- and 16-richery and binary. These are sections A1, B11. But there are tasks with other number systems, such as in section B7.

To begin with, we will remind two tables that would be good to know by heart to those who choose computer science with their further profession.

Table of degrees 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 on 2. So that if you remember not all these numbers, the others are not difficult to get in the mind of those that remember.

Table of binary numbers from 0 to 15 C 16-Rica 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 \u200b\u200bare also easy to calculate, adding 1 to known values.

Translation of integers

So, let's start with the translation immediately into the binary system. Take the same number 810 10. We need to decompose this number on the components equal to the degree of two.

  1. We are looking for the nearest to 810 degree, not exceeding it. This is 2 9 \u003d 512.
  2. We subtract 512 of 810, we get 298.
  3. We repeat steps 1 and 2 until 1 or 0 remains.
  4. We did it: 810 \u003d 512 + 256 + 32 + 8 + 2 \u003d 2 9 + 2 8 + 2 5 + 2 3 + 2 1.
Next there are two ways, you can use any of them. How it is easy 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 foundation of the number system is 1 (one), and so much zeros, what is the degree.

Method 1.: Plan 1 for those discharges, what are the indicators of the components. In our example, it is 9, 8, 5, 3 and 1. The remaining places will be zeros. So, we got a binary representation of the number 810 10 \u003d 1100101010 2. Units are on the 9th, 8th, 5th, 3rd and 1st places, counting on the right left from scratch.

Method 2: Sick the terms as degrees of each other, starting with more.

810 =

And now lay these steps together, how fan are folded: 1100101010.

That's all. Also, it is also simply solved by the task "How many units in the binary recording of the number 810?".

The answer is as much as the terms (degrees) in such a representation. In 810 of them 5.

Now an example is simpler.

We translate the number 63 in a 5-round number system. The closest to 63 degree of number 5 is 25 (square 5). Cube (125) will already have a lot. That is, 63 lies between square 5 and cube. Then we will select the coefficient for 5 2. This is 2.

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

Well, finally, completely light translations between 8- and 16-richery systems. Since their foundation is a degree of twos, then the translation is made automatically, simply replacing the numbers to their binary representation. For the 8-riche system, each digit is replaced with three binary discharges, and for 16-riche four. At the same time, all the leading zeros are mandatory, except the oldest discharge.

We translate into the binary system number 547 8.

547 8 = 101 100 111
5 4 7

Another one, for example, 7D6A 16.

7D6A 16 \u003d. (0)111 1101 0110 1010
7 D. 6 A.

I will transfer the number 7368 to the 16-star system. First, the numbers will write down the top three, and then divide them on the fours from the end: 736 8 \u003d 111 011 110 \u003d 1 1101 1110 \u003d 1DE 16. We translate into the 8-star system number C25 16. First, the numbers will write down four, and then share them on the top three from the end: C25 16 \u003d 1100 0010 0101 \u003d 110 000 100 101 \u003d 6045 8. Now consider the translation back to the decimal. He does not represent it, the main thing is not to be mistaken in the calculations. Unlock the number on the polynomial with the degrees of the base and the coefficients for them. Then everything is multiplied and fold. E68 16 \u003d 14 * 16 2 + 6 * 16 + 8 \u003d 3688. 732 8 \u003d 7 * 8 2 + 3 * 8 + 2 \u003d 474.

Translation of negative numbers

Here you need to consider that the number will be presented in the additional code. To transfer the number to the additional code, you need to know the final size of the number, that is, what we want to enter it - in bytes, in two bytes, four. The senior discharge of the number means a sign. If there is 0, then the number is positive, if 1, then negative. On the left, the number is complemented by a sign discharge. We do not consider unsigned (unsigned) numbers, they are always positive, and the elder discharge in them is used as informational.

For translate negative number In binary optional code you need to translate a positive number into the binary system, then change zeros by units and units to zeros. Then add to the result 1.

So, we will transfer the number -79 to the binary system. The number will take one byte.

We translate 79 to the binary system, 79 \u003d 1001111. Supplement from the left to the size of the byte, 8 of the discharges, we obtain 01001111. We change 1 to 0 and 0 to 1. Get 10110000. I add 1 to the result 1, we get the answer 10110001. Along the way, we answer the question of the exam "How many units in the binary representation of the number -79?". Answer - 4.

The addition of 1 to the inversion of the number allows you to eliminate the difference between the views +0 \u003d 00000000 and -0 \u003d 11111111. In the additional code, they will be recorded equally 00000000.

Translation of fractional numbers

Fractional numbers are translated by a way, reverse division of integers on the ground that we looked at at the very beginning. That is, with the help of consistent multiplication to a new base with collecting integer parts. The integers obtained by multiply are collected, but do not participate in the following operations. Only fractional are multiplied. If the initial number is greater than 1, then the whole and fractional part are translated separately, then glued.

We translate 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 obtain all zeros in the fractional part or the required accuracy will be achieved. Let us dwell while on the 6th sign.

It turns out 0.6752 \u003d 0,101011.

If the number was 5.6752, then in binary form it will be 101,101011.

The calculator allows you to transfer integers and fractional numbers from one number system to another. The base of the number system cannot be less than 2 and more than 36 (10 digits and 26 Latin letters after all). The length of numbers should not exceed 30 characters. To enter fractional numbers, use a symbol. or, . To translate a number from one system to another, enter the source number in the first field, the base of the source number system to the second and the base of the number system to which you want to translate the number in the third field, and then click the "Get Record" button.

Source number Recorded at 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 36 System number system.

I want to get a record of the number in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 System number system.

Get writing

Translation performed: 3336969

It may also be interesting:

  • TRID Table Calculator. SDNF. SKFF. Polin Zhegalkina

Number systems

Numbers are divided into two types: positional and not positional. We use the Arab system, it is a positional, and there is another Roman - it is just not a positional one. In the positional systems, the position of the numbers in the number uniquely determines the value of this number. It is easy to understand, examined on the example of some number.

Example 1.. Take the number 5921 in the decimal number system. Number the number on the right left since scratch:

The number 5921 can be written in the following form: 5921 \u003d 5000 + 900 + 20 + 1 \u003d 5 · 10 3 + 9 · 10 2 + 2 · 10 1 + 1 · 10 0. The number 10 is a characteristic that defines the number system. As degrees, the positions of the number of this number are taken.

Example 2.. Consider real decimal number 1234.567. Number it starting from the zero position of the number from the decimal point to the left and right:

The number 1234.567 can be written in the following form: 1234.567 \u003d 1000 + 200 + 30 + 4 + 0.5 + 0.06 + 0.007 \u003d 1 · 10 3 + 2 · 10 2 + 3 · 10 1 + 4 · 10 0 + 5 · 10 -1 + 6 · 10 -2 + 7 · 10 -3.

Translation of numbers from one number system to another

The simplest way to translate numbers from one number system to another is the translation of the number first into a decimal number system, and then the result obtained in the desired number system.

Translation of numbers from any number system in a decimal number system

To transfer the number from any number system to decimal, it is enough to numbered its discharges, starting with zero (discharge from the decimal point), similar to examples 1 or 2. Find the amount of the number of numbers on the base of the number system to the degree of position of this figure:

1. Transfer the number 1001101.1101 2 to a decimal number system.
Decision: 10011.1101 2 \u003d 1 · 2 4 + 0 · 2 3 + 0 · 2 2 + 1 · 2 1 + 1 · 2 0 + 1 · 2 -1 + 1 · 2 -2 + 0 · 2 -3 + 1 · 2 - 4 \u003d 16 + 2 + 1 + 0.5 + 0.25 + 0.0625 \u003d 19.8125 10
Answer: 10011.1101 2 = 19.8125 10

2. Transfer the number E8F.2D 16 to a decimal number system.
Decision: E8F.2D 16 \u003d 14 · 16 2 + 8 · 16 1 + 15 · 16 0 + 2 · 16 -1 + 13 · 16 -2 \u003d 3584 + 128 + 15 + 0.125 + 0.05078125 \u003d 3727.17578125 10
Answer: E8F.2D 16 \u003d 3727.17578125 10

Translation of numbers from a decimal number system to another number system

To transfer numbers from decimal system You need to translate into another number system to another number and fractional parts of the number separately.

Transfer of a whole part of the number from a decimal number system to another number system

The integer part is translated from a decimal number system to another number system using a sequential division of a whole part of the number based on the number of the number system until a whole balance is obtained, a smaller base system base. The result of the translation will be an entry from residues, starting with the latter.

3. Transfer the number 273 10 to an eight-lit count.
Decision: 273/8 \u003d 34 and residue 1, 34/8 \u003d 4 and residue 2, 4 less than 8, so the calculations are completed. Recording from residues will have the following form: 421
Check: 4 · 8 2 + 2 · 8 1 + 1 · 8 0 \u003d 256 + 16 + 1 \u003d 273 \u003d 273, the result coincided. So the translation is performed correctly.
Answer: 273 10 = 421 8

Consider the translation of the right decimal fractions in various systems Note.

Translation of the fractional part of the number from the decimal number system to another number system

Recall, right decimal fraction called total number With zero whole part . In order to translate such a number into the NUMBA system with the base n, you need to multiply the number on n until the fractional part is reset or the required number of discharges will not be obtained. If the multiplication is obtained with a whole part, different from zero, then the whole part is not taken into account, as it is consistently entered into the result.

4. Transfer a number 0.125 10 to a binary number system.
Decision: 0.125 · 2 \u003d 0.25 (0 - a whole part that will be the first digit of the result), 0.25 · 2 \u003d 0.5 (0 - the second digit of the result), 0.5 · 2 \u003d 1.0 (1 - the third digit of the result, and since the fractional part is zero , then the translation is completed).
Answer: 0.125 10 = 0.001 2

Methods for translation numbers from one number system to another.

Translation of numbers from one positioning system to another: Transfer of integers.

To translate an integer from one number system with the base D1 to another with the base D2, it is necessary to sequentially divide this number and the received private on the base D2 new system As long as it turns out the private less than the base D2. The last private is the older number of the number in the new number system with the base D2, and the numbers behind it are the remnants of the division recorded in the sequence returning them. Arithmetic actions to perform in the system of the number in which the translated number is recorded.

Example 1. Translate the number 11 (10) into a binary number system.

Answer: 11 (10) \u003d 1011 (2).

Example 2. Translate the number 122 (10) into the octal number system.


Answer: 122 (10) \u003d 172 (8).

Example 3. Translate the number 500 (10) into a hexadecimal number system.


Answer: 500 (10) \u003d 1F4 (16).

Translation of numbers from one positional number system to another: Translation of the right fractions.

To translate the correct fraction of the number system with the base D1 into the system with the base D2, you must consistently multiply the initial fraction and fractional parts of the resulting works on the base of the new D2 number system. The correct fraction of the number in the new number system with the base D2 is formed in the form of integers of the resulting works, starting from the first.
If a translating is obtained in the form of an infinite or diverging row, the process can be finished when the required accuracy is achieved.

When transferring mixed numbers, it is necessary to translate separately and fractional parts to the new system according to the rules for the transfer of integers and the correct fractions, and then both results are combined into one mixed number in a new number system.

Example 1. Translate a number 0.625 (10) to a binary number system.


Answer: 0,625 (10) \u003d 0.101 (2).

Example 2. Translate a number 0.6 (10) to an octal number system.


Answer: 0.6 (10) \u003d 0.463 (8).

Example 2. Translate a number 0.7 (10) to a hexadecimal number system.


Answer: 0.7 (10) \u003d 0, B333 (16).

Translation of binary, octal and hexadecimal numbers in a decimal number system.

To transfer the number of the P-smoked system to decimal, it is necessary to use the following decomposition formula:
ANAN-1 ... A1A0 \u003d Аnpn + an-1pn-1 + ... + a1p + a0.

Example 1. Translate the number 101.11 (2) into a decimal number system.

Answer: 101.11 (2) \u003d 5.75 (10).

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

Answer: 57.24 (8) \u003d 47,3125 (10).

Example 3. Translate the number 7A, 84 (16) into a decimal number system.

Answer: 7a, 84 (16) \u003d 122.515625 (10).


Transfer of octal and hexadecimal numbers into a binary number system and back.

To transfer the number from an octal numbering system to binary, each number of this number is necessary to record a three-digit binary number (triad).

Example: Record number 16.24 (8) in a binary number system.


Answer: 16.24 (8) \u003d 1110,0101 (2).

For the reverse translation of the binary number in the octal number system, the initial number is necessary to divide the triads to the left and right from the comma and present each group in the octaous number system. Extreme incomplete triads are complemented by zeros.

Example: Record the number 1110,0101 (2) in the octaous number system.


Answer: 1110,0101 (2) \u003d 16.24 (8).

To transfer the number from a hexadecimal number system to binary, each figure of this number is necessary to record a four-digit binary number (notebook).

Example: Record the number 7a, 7e (16) in the binary number system.


Answer: 7a, 7e (16) \u003d 1111010,0111111 (2).

Note: insignificant zeros on the left for integers and on the right for fractions are not recorded.

For the reverse translation of the binary number into a hexadecimal number system, the initial number is necessary to split down to the tetrads to the left and right from the comma and present each group in the hexadecimal number system. Extreme incomplete triads are complemented by zeros.

Example: Record the number 1111010,0111111 (2) in a hexadecimal number system.

1. Several account in various number systems.

In modern life, we use positional numbering systems, that is, systems in which the number indicated by the number depends on the number of numbers in the record of the number. Therefore, in the future, we will only talk about them, the lowering term "positional".

In order to learn how to translate numbers from one system to another, we will understand how the sequential recording of the numbers on the example of the decimal system occurs.

Since we have a decimal number system, we have 10 characters (numbers) to build numbers. We begin the sequence account: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The numbers ended. We increase the size of the number and reset the younger discharge: 10. Then we increase the younger discharge again until all the numbers are run out: 11, 12, 13, 14, 15, 16, 17, 18, 19. We increase the eldest discharge by 1 and reset the younger: 20. When we use all the numbers for both discharges (we get the number 99), we again increase the size of the number and reset the available discharges: 100. And so on.

Let's try to do the same in 2, 3rd and 5th systems (we introduce the designation for the 2nd system, for 3rd, etc.):

0 0 0 0
1 1 1 1
2 10 2 2
3 11 10 3
4 100 11 4
5 101 12 10
6 110 20 11
7 111 21 12
8 1000 22 13
9 1001 100 14
10 1010 101 20
11 1011 102 21
12 1100 110 22
13 1101 111 23
14 1110 112 24
15 1111 120 30

If the number system has a base greater than 10, we will have to introduce additional characters, it is customary to enter the letters of the Latin alphabet. For example, for a 12-riche system except ten-digit, we will need two letters (s):

0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10
11
12 10
13 11
14 12
15 13

2. Transfer from a decimal number system to any other.

To translate an integer positive decimal number into a number system with a different base, you need to divide this number to the base. The obtained private is again divided into the base, and further until the private will be less than the base. As a result, write to one line the last private and all the remnants starting with the latter.

Example 1. We transfer the decimal number 46 to the binary number system.

Example 2. We transfer the decimal number 672 in the octal number system.

Example 3. We translate the decimal number 934 in a hexadecimal number system.

3. Transfer from any number system to decimal.

In order to learn how to translate numbers from any other system to decimal, we analyze the decimal number we are familiar to us.
For example, the decimal number 325 is 5 units, 2 dozen and 3 hundred, i.e.

The same is the same in other number systems, only multiply will not be 10, 100, etc., but to the degree of the foundation of the number system. For example, take the number 1201 in the Trooked Number System. Number discharges to the right left starting from scratch and present our number as the amount of the pieces of numbers on the top to the degree of discharge of the number:

This is the decimal record of our number, i.e.

Example 4. We transfer to the decimal number system of the octal number 511.

Example 5. We transfer to the decimal number system hexadecimal number 1151.

4. Transfer from binary system to the system with a "degree" (4, 8, 16, etc.).

To convert binary numbers to a number with a "degree degree" base, a binary sequence is necessary to split into groups by number of digits to equally left to the right and to replace the corresponding digit of the new number system.

For example, we will translate binary 1100001111010110 number in the octal system. To do this, we break it into groups of 3 characters starting on the right (because), and then use the matching table and replace each group to a new figure:

We learned how to build conformity table in claim 1.

0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7

Those.

Example 6. We translate binary 1100001111010110 number in a hexadecimal system.

0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
1001 9
1010 A.
1011 B.
1100 C.
1101 D.
1110 E.
1111 F.

5. Transfer from the system with the basis of "degree of two" (4, 8, 16, etc.) into binary.

This translation is similar to the previous, completed in the opposite direction: each number we replace the digit group in the binary system from the matching table.

Example 7. We translate the hex number C3A6 to the binary number system.

To do this, every figure of the number is replaced by a group of 4 digits (because) from the correspondence table, adding a group with zeros at the beginning: