Features of translating numbers into different number systems. Number systems. Transfer from one system to another. Binary number system

Consider ways to translate numbers from one number system to another.

a) Converting a binary number to decimal.

It is necessary to add twos in powers corresponding to the positions where ones are in binary. For example:

Take the number 20. In binary, it looks like this: 10100.

So (counting from left to right, counting from 4 to 0; a number to the power of zero is always equal to one)

10100 = 1*2 4 + 0*2 3 + 1*2 2 + 0*2 1 + 0*2 0 = 20

16+0+4+0+0 = 20.

b) Converting a decimal number to binary.

It is necessary to divide it by two, writing the remainder from right to left:

20/2 = 10, remainder 0

10/2=5, remainder 0

5/2=2, remainder 1

2/2=1, remainder 0

1/2=0, remainder 1

As a result, we get: 10100 = 20

c) Converting a hexadecimal number to decimal.

In the hexadecimal system, the position number of the digit in the number corresponds to the power to which the number 16 must be raised:

8A=8*16+10(0A)=138

Finally, we present an algorithm for converting to and from a binary system, proposed by L. Radyuk.

Let A(cd) be an integer decimal number. We write it as the sum of powers of base 2 with binary coefficients. In its expanded form, there will be no negative degrees of base (number 2):

A(cd) = a(n-1) * 2^(n-1) + a(n-2) * 2^(n-2) + … + a(1) * 2^1 + a(0) *2^0.

At the first step, we divide the number A (tsd) by the base of the binary system, that is, by 2. The quotient of division will be equal to:

a(n-1) * 2^(n-2) + a(n-2) * 2^(n-3) + ... + a(1) and the remainder is a(0).

At the second step, the integer quotient is again divided by 2, the remainder of the division will now be equal to a (1).

If we continue this division process, then after the nth step we get a sequence of residues:

a(0), a(1),…, a(n-1).

It is easy to see that their sequence coincides with the reverse sequence of digits of a binary integer written in folded form:

A(2) = a(n-1)…a(1)a(0).

Thus, it is enough to write the remainders in reverse order to get the desired binary number.

Then the algorithm itself will be as follows:

1. Consistently perform the division of the original integer decimal number and the resulting integer quotients by the base of the system (by 2) until a quotient is obtained that is less than the divisor, that is, less than 2.

2. Write down the resulting balances in reverse order, and add the last quotient on the left.

To convert numbers from octal and hexadecimal to binary, you need to convert the digits of the number into groups of binary digits. To convert from the octal system to binary, each digit of the number must be converted into a group of three binary digits a triad, and when converting a hexadecimal number into a group of four digits, a tetrad.

CONCLUSION

Summarizing the results of the work, the following conclusions can be drawn.

The positional number system consists in using a limited number of digits, but the position of each digit in the number provides the significance (weight) of this digit. The position of a digit in a number in mathematical language is called a digit.

The base of a positional number system is the number of different characters or symbols (digits) used to display numbers in a given system.

In order to make binary numbers, which differ in a rather significant length, easier to perceive and display, they are compressed into octal and hexadecimal number systems.

In computer technology, all types of information are encoded only by numbers or, more precisely, by numbers that are represented in the binary system, the way any numbers are represented using two characters (numbers) according to the positional principle.

From 16 or 8 to 2

Translation octal And hexadecimal numbers into the binary system very simple: it is enough to replace each digit with its equivalent binary triad(three digits) or tetrad(four digits) (see table).
Binary (Base 2) Octal (Base 8) Decimal (Base 10) Hexadecimal (Base 16)
triads tetrads
0 1 0 1 2 3 4 5 6 7 000 001 010 011 100 101 110 111 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 A B C D E F 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

For example:

a) Translate 305.4 8 "2" s.s.

b) Translate 7B2.E 16 "2" s.s.

16A 16 = 1 0110 1010 2 345 8 = 11 100 101 2

From 2 to 16 or 8

For example:

a) Translate 1101111001.1101 2 "8" s.s.

b) Translate 11111111011.100111 2 "16" s.s.

1000101010010101 2 =1000 1010 1001 0101=8A95 16 = 1000 101 010 010 101=105225 8

From 16 to 8 and back

Translation from octal to hexadecimal system and vice versa is carried out through the binary system using triads and tetrads.

For example:

Translate 175.24 8 "16" s.s.

Result: 175.24 8 = 7D.5 16 .

From 10 to any s.s.

For example:

a) Translate 181 10 "8" s.s.

Result: 181 10 = 265 8

b) Translate 622 10 "16" s.s.

Result: 622 10 = 26E 16

Translation of proper fractions
To convert a correct decimal fraction to another system, this fraction must be successively multiplied by the base of the system into which it is being converted. In this case, only fractional parts are multiplied. The fraction in the new system is written as whole parts of products, starting from the first.

For example:

Convert 0.3125 10 "8" s.s.

Result: 0.3125 10 = 0.24 8

Comment. A finite decimal fraction in another number system can correspond to an infinite (sometimes periodic) fraction. In this case, the number of characters in the representation of the fraction in the new system is taken depending on the required accuracy.

For example:

Translate 0.65 10 "2" s.s. Accuracy 6 characters.

Result: 0.65 10 0.10(1001) 2

To convert an improper decimal fraction to a number system with a non-decimal base it is necessary to translate the whole part separately and the fractional part separately.

For example:

Translate 23.125 10 "2" s.s.

Thus: 23 10 = 10111 2 ; 0.12510 = 0.0012.
Result: 23.125 10 = 10111.001 2 .

It should be noted that integers remain integers, and proper fractions remain fractions in any number system.

From 2, 8 or 16 to 10

For example:

a)10101101.101 2 = 1 2 7 + 0 2 6 + 1 2 5 + 0 2 4 + 1 2 3 + 1 2 2 + 0 2 1 + 1 2 0 + 1 2 -1 + 0 2 -2 + 1 2 - 3 = 173.625 10

b) Translate 703.04 8 "10" s.s.

703.04 8 = 7 8 2 + 0 8 1 + 3 8 0 + 0 8 -1 + 4 8 -2 = 451.0625 10

c) Translate B2E.4 16 "10" s.s.

B2E.4 16 = 11 16 2 + 2 16 1 + 14 16 0 + 4 16 -1 = 2862.25 10

Scheme for converting numbers from one number system to another


Arithmetic operations in positional number systems

Consider the basic arithmetic operations: addition, subtraction, multiplication and division. The rules for performing these operations in the decimal system are well known - this is addition, subtraction, multiplication by a column and division by an angle. These rules apply to all other positional number systems. Only tables of addition and multiplication should be used specific for each system.

Addition

When adding, the numbers are summed up by digits, and if an excess occurs, then it is transferred to the left

When adding binary numbers in each digit, the digits of the terms and the transfer from the adjacent low-order digit, if any, are added. It should be taken into account that 1 + 1 gives a zero in a given bit and a unit of transfer to the next one.

For example:

Perform binary addition:
a) X=1101, Y=101;

Result 1101+101=10010.

b) X=1101, Y=101, Z=111;

Result 1101+101+111=11001.

Addition table in the 8th number system

2+2=4 3+2=5 4+2=6 5+2=7 6+2=10 7+2=11
2+3=5 3+3=6 4+3=7 5+3=10 6+3=11 7+3=12
2+4=6 3+4=7 4+4=10 5+4=11 6+4=12 7+4=13
2+5=7 3+5=10 4+5=11 5+5=12 6+5=13 7+5=14
2+6=10 3+6=11 4+6=12 5+6=13 6+6=14 7+6=15
2+7=11 3+7=12 4+7=13 5+7=14 6+7=15 7+7=16

Addition table in the 16th number system

+ A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A A B C D E F
B B C D E F 1A
C C D E F 1A 1B
D D E F 1A 1B 1C
E E F 1A 1B 1C 1D
F F 1A 1B 1C 1D 1E

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

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

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

Table 4. Powers of 2

n (degree)

Example.

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

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

Table 5. Powers of 8

n (degree)

Example. Convert the number to decimal number system.

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

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

Table 6. Powers of 16

n (degree)

Example. Convert the number to decimal number system.

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

Example. Convert the number to binary number system.

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

Example. Convert the number to octal number system.

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

Example. Convert the number to hexadecimal.

With this online calculator you can convert whole and fractional numbers from one number system to another. A detailed solution with explanations is given. To translate, enter the original number, set the base of the number system of the original number, set the base of the number system to which you want to convert the number and click the "Translate" button. See the theoretical part and numerical examples below.

The result has already been received!

Translation of integer and fractional numbers from one number system to any other - theory, examples and solutions

There are positional and non-positional number systems. The Arabic number system that we use in everyday life is positional, while the Roman one is not. In positional number systems, the position of a number uniquely determines the magnitude of the number. Consider this using the example of the number 6372 in the decimal number system. Let's number this number from right to left starting from zero:

Then the number 6372 can be represented as follows:

6372=6000+300+70+2 =6 10 3 +3 10 2 +7 10 1 +2 10 0 .

The number 10 defines the number system (in this case it is 10). The values ​​of the position of the given number are taken as degrees.

Consider the real decimal number 1287.923. We number it starting from the zero position of the number from the decimal point to the left and to the right:

Then the number 1287.923 can be represented as:

1287.923 =1000+200+80 +7+0.9+0.02+0.003 = 1 10 3 +2 10 2 +8 10 1 +7 10 0 +9 10 -1 +2 10 -2 +3 10 -3 .

In general, the formula can be represented as follows:

C n s n + C n-1 s n-1 +...+C 1 s 1 + C 0 s 0 + D -1 s -1 + D -2 s -2 + ... + D -k s -k

where C n is an integer in position n, D -k - fractional number in position (-k), s- number system.

A few words about number systems. A number in the decimal number system consists of a set of digits (0,1,2,3,4,5,6,7,8,9), in the octal number system it consists of a set of digits (0,1, 2,3,4,5,6,7), in the binary system - from the set of digits (0.1), in the hexadecimal number system - from the set of digits (0,1,2,3,4,5,6, 7,8,9,A,B,C,D,E,F), where A,B,C,D,E,F correspond to numbers 10,11,12,13,14,15. In Table 1 numbers are represented in different number systems.

Table 1
Notation
10 2 8 16
0 0 0 0
1 1 1 1
2 10 2 2
3 11 3 3
4 100 4 4
5 101 5 5
6 110 6 6
7 111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F

Converting numbers from one number system to another

To translate numbers from one number system to another, the easiest way is to first convert the number to the decimal number system, and then, from the decimal number system, translate it into the required number system.

Converting numbers from any number system to decimal number system

Using formula (1), you can convert numbers from any number system to the decimal number system.

Example 1. Convert the number 1011101.001 from binary number system (SS) to decimal SS. Solution:

1 2 6 +0 2 5 + 1 2 4 + 1 2 3 + 1 2 2 + 0 2 1 + 1 2 0 + 0 2 -1 + 0 2 -2 + 1 2 -3 =64+16+8+4+1+1/8=93.125

Example2. Convert the number 1011101.001 from octal number system (SS) to decimal SS. Solution:

Example 3 . Convert the number AB572.CDF from hexadecimal to decimal SS. Solution:

Here A-replaced by 10, B- at 11, C- at 12, F- at 15.

Converting numbers from a decimal number system to another number system

To convert numbers from a decimal number system to another number system, you need to translate the integer part of the number and the fractional part of the number separately.

The integer part of the number is translated from the decimal SS to another number system - by successively dividing the integer part of the number by the base of the number system (for binary SS - by 2, for 8-digit SS - by 8, for 16-digit - by 16, etc. ) to obtain a whole remainder, less than the base of the SS.

Example 4 . Let's translate the number 159 from decimal SS to binary SS:

159 2
158 79 2
1 78 39 2
1 38 19 2
1 18 9 2
1 8 4 2
1 4 2 2
0 2 1
0

As can be seen from Fig. 1, the number 159, when divided by 2, gives the quotient 79 and the remainder is 1. Further, the number 79, when divided by 2, gives the quotient 39 and the remainder is 1, and so on. As a result, by constructing a number from the remainder of the division (from right to left), we get a number in binary SS: 10011111 . Therefore, we can write:

159 10 =10011111 2 .

Example 5 . Let's convert the number 615 from decimal SS to octal SS.

615 8
608 76 8
7 72 9 8
4 8 1
1

When converting a number from decimal SS to octal SS, you need to sequentially divide the number by 8 until you get an integer remainder less than 8. As a result, building a number from the remainder of the division (from right to left) we get a number in octal SS: 1147 (see Fig. 2). Therefore, we can write:

615 10 =1147 8 .

Example 6 . Let's translate the number 19673 from the decimal number system to hexadecimal SS.

19673 16
19664 1229 16
9 1216 76 16
13 64 4
12

As can be seen from Figure 3, by successively dividing the number 19673 by 16, we got the remainders 4, 12, 13, 9. In the hexadecimal number system, the number 12 corresponds to C, the number 13 - D. Therefore, our hexadecimal number is 4CD9.

To convert correct decimal fractions (a real number with a zero integer part) into a number system with base s, this number must be successively multiplied by s until the fractional part is pure zero, or we get the required number of digits. If the multiplication results in a number with an integer part other than zero, then this integer part is not taken into account (they are sequentially included in the result).

Let's look at the above with examples.

Example 7 . Let's translate the number 0.214 from the decimal number system to binary SS.

0.214
x 2
0 0.428
x 2
0 0.856
x 2
1 0.712
x 2
1 0.424
x 2
0 0.848
x 2
1 0.696
x 2
1 0.392

As can be seen from Fig.4, the number 0.214 is successively multiplied by 2. If the result of multiplication is a number with an integer part other than zero, then the integer part is written separately (to the left of the number), and the number is written with a zero integer part. If, when multiplied, a number with a zero integer part is obtained, then zero is written to the left of it. The multiplication process continues until a pure zero is obtained in the fractional part or the required number of digits is obtained. Writing bold numbers (Fig. 4) from top to bottom, we get the required number in the binary system: 0. 0011011 .

Therefore, we can write:

0.214 10 =0.0011011 2 .

Example 8 . Let's translate the number 0.125 from the decimal number system to the binary SS.

0.125
x 2
0 0.25
x 2
0 0.5
x 2
1 0.0

To convert the number 0.125 from decimal SS to binary, this number is successively multiplied by 2. In the third stage, 0 was obtained. Therefore, the following result was obtained:

0.125 10 =0.001 2 .

Example 9 . Let's translate the number 0.214 from the decimal number system to hexadecimal SS.

0.214
x 16
3 0.424
x 16
6 0.784
x 16
12 0.544
x 16
8 0.704
x 16
11 0.264
x 16
4 0.224

Following examples 4 and 5, we get the numbers 3, 6, 12, 8, 11, 4. But in hexadecimal SS, the numbers C and B correspond to the numbers 12 and 11. Therefore, we have:

0.214 10 =0.36C8B4 16 .

Example 10 . Let's translate the number 0.512 from the decimal number system to the octal SS.

0.512
x 8
4 0.096
x 8
0 0.768
x 8
6 0.144
x 8
1 0.152
x 8
1 0.216
x 8
1 0.728

Got:

0.512 10 =0.406111 8 .

Example 11 . Let's translate the number 159.125 from the decimal number system to binary SS. To do this, we translate separately the integer part of the number (Example 4) and the fractional part of the number (Example 8). Combining these results, we get:

159.125 10 =10011111.001 2 .

Example 12 . Let's translate the number 19673.214 from the decimal number system to hexadecimal SS. To do this, we translate separately the integer part of the number (Example 6) and the fractional part of the number (Example 9). Further combining these results we get.

1. Ordinal counting in various number systems.

In modern life, we use positional number systems, that is, systems in which the number denoted by a digit depends on the position of the digit in the notation of the number. Therefore, in the future we will only talk about them, omitting the term "positional".

In order to learn how to translate numbers from one system to another, let's understand how the sequential recording of numbers takes place using the decimal system as an example.

Since we have a decimal number system, we have 10 characters (digits) to build numbers. We start the ordinal count: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The numbers are over. We increase the capacity of the number and reset the low order: 10. Then again increase the low order until all the digits run out: 11, 12, 13, 14, 15, 16, 17, 18, 19. Increase the high order by 1 and set the low order to zero: 20. When we use all the digits for both digits (we get the number 99), we again increase the digit capacity of the number and reset the existing digits: 100. And so on.

Let's try to do the same in the 2nd, 3rd, and 5th systems (let's introduce the notation for the 2nd system, for the 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, then we will have to enter additional characters, it is customary to enter letters of the Latin alphabet. For example, for the hexadecimal system, in addition to ten digits, we need two letters ( and ):

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 decimal number system to any other.

To convert a whole positive decimal number to a number system with a different base, you need to divide this number by the base. The resulting quotient is again divided by the base, and further until the quotient is less than the base. As a result, write the last quotient and all the remainders in one line, starting with the last one.

Example 1 Let's translate the decimal number 46 into the binary number system.

Example 2 Let's translate the decimal number 672 into the octal number system.

Example 3 Let's translate the decimal number 934 into the hexadecimal number system.

3. Translation from any number system to decimal.

In order to learn how to translate numbers from any other system into decimal, let's analyze the decimal notation familiar to us.
For example, the decimal number 325 is 5 units, 2 tens and 3 hundreds, i.e.

The situation is exactly the same in other number systems, only we will multiply not by 10, 100, etc., but by the degree of the base of the number system. For example, let's take the number 1201 in the ternary number system. We number the digits from right to left starting from zero and represent our number as the sum of the products of a digit by a triple in the degree of a number digit:

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

Example 4 Let's convert the octal number 511 to the decimal number system.

Example 5 Let's convert the hexadecimal number 1151 to the decimal number system.

4. Transfer from a binary system to a system with a "power of two" base (4, 8, 16, etc.).

To convert a binary number to a number with a base "power of two", it is necessary to divide the binary sequence into groups according to the number of digits equal to the degree from right to left and replace each group with the corresponding digit of the new number system.

For example, Let's convert the binary number 1100001111010110 to octal. To do this, let's break it into groups of 3 characters starting from the right (because ), and then use the correspondence table and replace each group with a new number:

We learned how to build a correspondence table in paragraph 1.

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

Those.

Example 6 Let's convert the binary number 1100001111010110 to 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 a system with a base "power of two" (4, 8, 16, etc.) to binary.

This translation is similar to the previous one, made in the opposite direction: we replace each digit with a group of digits in the binary system from the correspondence table.

Example 7 Let's translate the hexadecimal number C3A6 into the binary number system.

To do this, we will replace each digit of the number with a group of 4 digits (because ) from the correspondence table, supplementing the group with zeros at the beginning if necessary:



 
Articles By topic:
Pasta with tuna in creamy sauce Pasta with fresh tuna in creamy sauce
Pasta with tuna in a creamy sauce is a dish from which anyone will swallow their tongue, of course, not just for fun, but because it is insanely delicious. Tuna and pasta are in perfect harmony with each other. Of course, perhaps someone will not like this dish.
Spring rolls with vegetables Vegetable rolls at home
Thus, if you are struggling with the question “what is the difference between sushi and rolls?”, We answer - nothing. A few words about what rolls are. Rolls are not necessarily Japanese cuisine. The recipe for rolls in one form or another is present in many Asian cuisines.
Protection of flora and fauna in international treaties AND human health
The solution of environmental problems, and, consequently, the prospects for the sustainable development of civilization are largely associated with the competent use of renewable resources and various functions of ecosystems, and their management. This direction is the most important way to get
Minimum wage (minimum wage)
The minimum wage is the minimum wage (SMIC), which is approved by the Government of the Russian Federation annually on the basis of the Federal Law "On the Minimum Wage". The minimum wage is calculated for the fully completed monthly work rate.