Translation from one number system to another by division. Translation of numbers into different number systems with a solution. Translation of integer and fractional numbers from one number system to any other - theory, examples and solutions

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 (cd) 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.

1. Ordinal counting in various number systems.

AT 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:

That's what it is decimal notation 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:



Rules for converting numbers from one number system to another

Since the same number can be written in different number systems (for example, ), the question arises of translating the representation of a number from one system to another. The translation rules for integer and fractional numbers are different.

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

Example. Convert to decimal number system

Decision:

Converting integers from one number system to another

1. Divide the given number by the new base, written as a number with the old base, until a remainder is obtained.

2. The resulting quotient should be again divided by a new base, and this process should be repeated until the quotient is less than the divisor.

3. The resulting remainders from division and the last quotient are written in the reverse order of those obtained during division.

Decision:

Translation of fractional numbers from one number system to another

Multiply the given number by the new base, written as a number with the old base. With each multiplication, the integer part of the product is taken as the next digit of the corresponding digit, and the remaining fractional part is taken as a new multiplicand. The number of multiplications determines the word length of the result.

Example. Convert number to binary, octal, hexadecimal number systems.

Decision:

Solution: Let's translate separately the integer and fractional parts of the number into the binary number system.

.

Combining the integer and fractional parts, we get

Since the binary, octal, and hexadecimal number systems are related to each other through powers of 2, conversions between them can be done in a simpler way.

1. To convert from a hexadecimal (octal) number system to a binary one, it is enough to write down the hexadecimal (octal) codes of digits in tetrads (triads) with a binary code.

2. The reverse translation from the binary code is performed in the reverse order: the binary number is divided to the left and right of the comma into tetrads for the subsequent recording of digits in hexadecimal representation and into triads for recording their values ​​in octal digits.

3. When changing from octal to hexadecimal and vice versa, an auxiliary, binary number code is used.

Example. Convert number to octal, hexadecimal number system.

Decision:

Example. Convert number to binary number system.

Decision:

To translate numbers from one number system to another, it is necessary to have basic knowledge of number systems and the form of representation of numbers in them.

Quantity s of various digits used in the number system is called the base, or the base of the number system. In general, a positive number X in positional system with base s can be represented as a polynomial:

where s- base of the number system, - digits allowed in this number system. The sequence forms an integer part X, and the sequence is the fractional part X.

In computing, the most widely used are binary (BIN - binary), and binary coded number systems: octal (OCT - octal), hexadecimal (HEX - hexadecimal) and binary coded decimal (BCD - binary coded decimal).

In the following, to indicate the number system used, the number will be enclosed in brackets, and the base of the system will be indicated in the index. Number X by reason s will be marked.

Binary number system

The base of the number system is the number 2 ( s= 2) and only two digits are used to write numbers: 0 and 1. To represent any bit of a binary number, it is enough to have a physical element with two clearly different stable states, one of which represents 1 and the other 0.

Before you start translating from any number system to binary, you need to carefully study the example of writing a number in the binary number system:

If you do not need to delve into the theory, but only need to get the result, then use Online calculator Converting integers from decimal to other systems .

Octal and hexadecimal number systems

These number systems are binary-coded, in which the base of the number system is an integer power of two: - for octal and - for hexadecimal.

In the octal number system ( s= 8) 8 digits are used: 0, 1, 2, 3, 4, 5, 6, 7.

Before you start translating from any number system to octal, you need to carefully study the example of writing a number in octal:

In hexadecimal number system ( s= 16) 16 digits are used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

An example of writing a number in hexadecimal system:

The widespread use of the octal and hexadecimal number systems is due to two factors.

Firstly, these systems make it possible to replace the notation of a binary number with a more compact representation (the notation of a number in octal and hexadecimal systems will be 3 and 4 times shorter than the binary notation of this number, respectively). Secondly, the mutual conversion of numbers between the binary system, on the one hand, and octal and hexadecimal, on the other, is relatively simple. Indeed, since for an octal number each digit is represented by a group of three binary digits (triads), and for a hexadecimal number - by a group of four binary digits (tetrads), then to convert a binary number, it is enough to combine its digits into groups of 3 or 4 digits, respectively, moving forward from the separating comma to the right and to the left. In this case, if necessary, zeros are added to the left of the integer part and / or to the right of the fractional part, and each such group - a triad or a tetrad - is replaced by an equivalent octal or hexadecimal digit (see table).

If you do not need to delve into the theory, but only need to get the result, then use Online calculator Converting integers from decimal to other systems .

Correspondence between digits in different number systems
DEC BIN OCT HEX BCD
0 0000 0 0 0000
1 0001 1 1 0001
2 0010 2 2 0010
3 0011 3 3 0011
4 0100 4 4 0100
5 0101 5 5 0101
6 0110 6 6 0110
7 0111 7 7 0111
8 1000 10 8 1000
9 1001 11 9 1001
10 1010 12 A 0001 0000
11 1011 13 B 0001 0001
12 1100 14 C 0001 0010
13 1101 15 D 0001 0011
14 1110 16 E 0001 0100
15 1111 17 F 0001 0101

For reverse translation, each OCT or HEX digit is replaced by a triad or tetrad of binary digits, respectively, with insignificant zeros on the left and right discarded.

For the previous examples, it looks like this:

If you do not need to delve into the theory, but only need to get the result, then use Online calculator Converting integers from decimal to other systems .

Binary Decimal Number System

In BCD, the weight of each digit is a power of 10, as in decimal, and each decimal digit is encoded with four binary digits. To write a decimal number in the BCD system, it is enough to replace each decimal digit with an equivalent four-digit binary combination:

Any decimal number can be represented in binary coded decimal notation, but remember that this is not the binary equivalent of a number. This can be seen from the following example:

Converting numbers from one number system to another

Let be X- a number in a number system with a base s, which is required to be represented in the system with the base h. It is convenient to distinguish between two cases.

In the first case and, consequently, when passing to the base h you can use the arithmetic of this system. The transformation method consists in representing the number as a polynomial in powers s, as well as in the calculation of this polynomial according to the rules of arithmetic of the number system with base h. So, for example, it is convenient to move from a binary or octal number system to a decimal number system. The described technique is illustrated by the following examples:

.

.

In both cases, arithmetic operations are performed according to the rules of the number system with base 10.

In the second case () it is more convenient to use base arithmetic s. Here it should be borne in mind that the translation of integers and proper fractions is carried out according to different rules. When translating mixed fractions, the integer and fractional parts are translated each according to their own rules, after which the resulting numbers are written separated by commas.

Integer Translation

The rules for translating integers become clear from the general formula for writing a number in an arbitrary positional system. Let the number in the original number system s looks like . It is required to get a record of a number in a number system with a base h:

.

To find the values, we divide this polynomial by h:

.

As you can see, the least significant digit, that is, is equal to the first remainder. The next significant digit is determined by dividing the quotient by h:

.

The rest are also calculated by dividing the quotients until it becomes zero.

To convert an integer from the s-ary number system to the h-ary one, it is necessary to sequentially divide this number and the resulting quotients by h (according to the rules of the number system with base h) until the quotient becomes zero. The highest digit in the record of a number with base h is the last remainder, and the digits following it form the remainders from the previous divisions, written out in the reverse order of their receipt.

Methods for converting numbers from one number system to another.

Translation of numbers from one positional number system to another: translation of 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 the d2 base of the new system until the quotient is less than the d2 base. The last quotient is the highest digit of the number in new system reckoning with base d2, and the numbers following it are the remainders of the division, written in the reverse order of their receipt. Perform arithmetic operations in the number system in which the translated number 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).

Translation of numbers from one positional number system to another: translation of proper fractions.

To convert a proper fraction from a number system with base d1 to a system with base d2, it is necessary to consistently 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 as 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 reached.

When translating mixed numbers, it is necessary to translate the integer and fractional parts separately into the 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.


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

Convert binary, octal and hexadecimal numbers to decimal.

To convert the number of the P-ary system to decimal, you must use the following expansion formula:
anan-1…a1a0=anPn+ an-1Pn-1+…+ a1P+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 binary and vice versa.

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

Example: Write down the number 16.24(8) in binary.


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

To convert a binary number back to 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 as a number in the octal number system. Extreme incomplete triads are completed with zeros.

Example: Write the number 1110.0101(2) in octal.


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

To convert a number from a hexadecimal number system to a binary one, each digit of this number must be written as a four-digit binary number (tetrad).

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


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

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

To convert a binary number back to 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 as a number in the hexadecimal number system. Extreme incomplete triads are completed with zeros.

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

mob_info