Translation from 10 code to binary. Converting numbers to different number systems with a solution

Service assignment. The service is designed to translate numbers from one number system to another online. To do this, select the base of the system from which you want to translate the number. You can enter both integers and numbers with a comma.

Number

Translation from 10 2 8 16 number system. Convert to 2 10 8 16 number system.
For fractional numbers, use 2 3 4 5 6 7 8 decimal places.

You can enter either whole numbers, such as 34 , or fractional numbers, such as 637.333 . For fractional numbers, the accuracy of the translation after the decimal point is indicated.

The following are also used with this calculator:

Ways to represent numbers

Binary (binary) numbers - each digit means the value of one bit (0 or 1), the most significant bit is always written on the left, the letter “b” is placed after the number. For ease of perception, notebooks can be separated by spaces. For example, 1010 0101b.
Hexadecimal (hexadecimal) numbers - each tetrad is represented by one character 0...9, A, B, ..., F. Such a representation can be denoted in different ways, here only the character "h" is used after the last hexadecimal digit. For example, A5h. In program texts, the same number can be denoted both as 0xA5 and 0A5h, depending on the syntax of the programming language. A non-significant zero (0) is added to the left of the most significant hexadecimal digit represented by a letter to distinguish between numbers and symbolic names.
Decimals (decimal) numbers - each byte (word, double word) is represented by an ordinary number, and the sign of the decimal representation (letter "d") is usually omitted. The byte from the previous examples has a decimal value of 165. Unlike binary and hexadecimal notation, decimal is difficult to mentally determine the value of each bit, which sometimes has to be done.
Octal (octal) numbers - each triple of bits (separation starts from the least significant) is written as a number 0-7, at the end the sign "o" is put. The same number would be written as 245o. The octal system is inconvenient in that the byte cannot be divided equally.

Algorithm for converting numbers from one number system to another

The conversion of integer decimal numbers to any other number system is carried out by dividing the number by the base of the new number system until the remainder leaves a number less than the base of the new number system. The new number is written as the remainder of the division, starting with the last one.
The conversion of the correct decimal fraction to another PSS is carried out by multiplying only the fractional part of the number by the base of the new number system until all zeros remain in the fractional part or until the specified translation accuracy is reached. As a result of each multiplication operation, one digit of the new number is formed, starting from the highest.
The translation of an improper fraction is carried out according to the 1st and 2nd rules. The integer and fractional parts are written together, separated by a comma.

Example #1.



Translation from 2 to 8 to 16 number system.
These systems are multiples of two, therefore, the translation is carried out using the correspondence table (see below).

To convert a number from a binary number system to an octal (hexadecimal) number, it is necessary to divide the binary number into groups of three (four for hexadecimal) digits from a comma to the right and left, complementing the extreme groups with zeros if necessary. Each group is replaced by the corresponding octal or hexadecimal digit.

Example #2. 1010111010.1011 = 1.010.111.010.101.1 = 1272.51 8
here 001=1; 010=2; 111=7; 010=2; 101=5; 001=1

When converting to hexadecimal, you must divide the number into parts, four digits each, following the same rules.
Example #3. 1010111010.1011 = 10.1011.1010.1011 = 2B12.13 HEX
here 0010=2; 1011=B; 1010=12; 1011=13

The conversion of numbers from 2, 8 and 16 to the decimal system is carried out by breaking the number into separate ones and multiplying it by the base of the system (from which the number is translated) raised to the power corresponding to its ordinal number in the translated number. In this case, the numbers are numbered to the left of the decimal point (the first number has the number 0) with increasing, and to the right with decreasing (ie, with a negative sign). The results obtained are added up.

Example #4.
Example of converting from binary to decimal number system.

1010010.101 2 = 1 2 6 +0 2 5 +1 2 4 +0 2 3 +0 2 2 +1 2 1 +0 2 0 + 1 2 -1 +0 2 - 2 +1 2 -3 =
= 64+0+16+0+0+2+0+0.5+0+0.125 = 82.625 10 Example of conversion from octal to decimal number system. 108.5 8 = 1* 8 2 +0 8 1 +8 8 0 + 5 8 -1 = 64+0+8+0.625 = 72.625 10 An example of converting from hexadecimal to decimal number system. 108.5 16 = 1 16 2 +0 16 1 +8 16 0 + 5 16 -1 = 256+0+8+0.3125 = 264.3125 10

Once again, we repeat the algorithm for translating numbers from one number system to another PSS

  1. From the decimal number system:
    • divide the number by the base of the number system being translated;
    • find the remainder after dividing the integer part of the number;
    • write down all remainders from division in reverse order;
  2. From the binary system
    • To convert to the decimal number system, you need to find the sum of the products of base 2 by the corresponding degree of discharge;
    • To convert a number to octal, you need to break the number into triads.
      For example, 1000110 = 1000 110 = 106 8
    • To convert a number from binary to hexadecimal, you need to divide the number into groups of 4 digits.
      For example, 1000110 = 100 0110 = 46 16
The system is called positional., for which the significance or weight of a digit depends on its location in the number. The relationship between systems is expressed in a table.
Table of correspondence of number systems:
Binary SSHexadecimal SS
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F

Table for converting to octal number system

2.3. Converting numbers from one number system to another

2.3.1. Converting integers from one number system to another

It is possible to formulate an algorithm for converting integers from a system with a base p into a system with a base q :

1. Express the base of the new number system in terms of the original number system and perform all subsequent actions in the original number system.

2. Consistently perform the division of the given number and the resulting integer quotients by the basis of the new number system until we get a quotient less than the divisor.

3. The resulting residues, which are the digits of a number in the new number system, must be brought into line with the alphabet of the new number system.

4. Compose a number in the new number system, writing it down starting from the last remainder.

Example 2.12. Convert decimal number 173 10 to octal number system:

We get: 173 10 \u003d 255 8

Example 2.13. Convert decimal number 173 10 to hexadecimal number system:

We get: 173 10 = AD 16 .

Example 2.14. Convert decimal number 11 10 to binary number system. The sequence of actions considered above (translation algorithm) is more conveniently depicted as follows:

We get: 11 10 \u003d 1011 2.

Example 2.15. Sometimes it is more convenient to write the translation algorithm in the form of a table. Let's translate the decimal number 363 10 into a binary number.

Divider

We get: 363 10 \u003d 101101011 2

2.3.2. Translation of fractional numbers from one number system to another

It is possible to formulate an algorithm for converting a proper fraction with a base p into a fraction with a base q:

1. Express the base of the new number system in terms of the original number system and perform all subsequent actions in the original number system.

2. Sequentially multiply the given number and the resulting fractional parts of the products by the basis of the new system until the fractional part of the product becomes equal to zero or the required accuracy of the representation of the number is reached.

3. The resulting integer parts of the products, which are the digits of a number in the new number system, are brought into line with the alphabet of the new number system.

4. Compose the fractional part of the number in the new number system, starting with the integer part of the first product.

Example 2.17. Convert the number 0.65625 10 to octal number system.

We get: 0.65625 10 \u003d 0.52 8

Example 2.17. Convert the number 0.65625 10 to hexadecimal number system.

x 16

We get: 0.65625 10 \u003d 0.A8 1

Example 2.18. Convert decimal 0.5625 10 to binary number system.

x 2

x 2

x 2

x 2

We get: 0.5625 10 \u003d 0.1001 2

Example 2.19. Convert to binary decimal 0.7 10 .

Obviously, this process can continue indefinitely, giving more and more signs in the image of the binary equivalent of the number 0.7 10 . So, in four steps we get the number 0.1011 2, and in seven steps the number 0.1011001 2, which is a more accurate representation of the number 0.7 10 in binary, etc. Such an endless process is interrupted at some step, when it is considered that the required accuracy of the number representation has been obtained.

2.3.3. Translation of arbitrary numbers

Translation of arbitrary numbers, i.e. numbers containing integer and fractional parts are carried out in two stages. The integer part is translated separately, and the fractional part is translated separately. In the final record of the resulting number, the integer part is separated from the fractional comma (dot).

Example 2.20. Convert number 17.25 10 to binary number system.

We get: 17.25 10 \u003d 1001.01 2

Example 2.21. Convert the number 124.25 10 to octal system.

We get: 124.25 10 \u003d 174.2 8

2.3.4. Converting numbers from a number system with base 2 to a number system with base 2 n and vice versa

Translation of integers. If the base of the q-ary number system is a power of 2, then the conversion of numbers from the q-ary number system to the 2-ary one and vice versa can be carried out according to simpler rules. In order to write a binary integer in a number system with base q=2 n, you need:

1. Divide a binary number from right to left into groups of n digits each.

2. If there are less than n digits in the last left group, then it must be supplemented on the left with zeros to the required number of digits.

Example 2.22. Let's translate the number 101100001000110010 2 into the octal number system.

We divide the number from right to left into triads and under each of them we write the corresponding octal digit:

We get the octal representation of the original number: 541062 8 .

Example 2.23. The number 1000000000111110000111 2 will be converted to hexadecimal number system.

We divide the number from right to left into tetrads and write the corresponding hexadecimal digit under each of them:

We get the hexadecimal representation of the original number: 200F87 16 .

Translation of fractional numbers. In order to write a fractional binary number in a number system with base q=2 n, you need:

1. Divide a binary number from left to right into groups of n digits each.

2. If there are less than n digits in the last right group, then it must be supplemented on the right with zeros to the required number of digits.

3. Consider each group as an n-bit binary number and write it down with the corresponding digit in the number system with base q=2 n .

Example 2.24. Let's translate the number 0.10110001 2 into the octal number system.

We divide the number from left to right into triads and write the corresponding octal digit under each of them:

We get the octal representation of the original number: 0.542 8 .

Example 2.25. Let's translate the number 0.100000000011 2 into hexadecimal number system. We divide the number from left to right into tetrads and write the corresponding hexadecimal digit under each of them:

We get the hexadecimal representation of the original number: 0.803 16

Translation of arbitrary numbers. In order to write an arbitrary binary number in the number system with base q=2 n, you need:

1. Divide the integer part of this binary number from right to left, and the fractional part from left to right into groups of n digits each.

2. If there are less than n digits in the last left and/or right groups, then they must be supplemented on the left and/or right with zeros up to the required number of digits;

3. Consider each group as an n-bit binary number and write it down as the corresponding digit in the number system with base q=2 n

Example 2.26. Let's translate the number 111100101.0111 2 into the octal number system.

We divide the integer and fractional parts of the number into triads and write the corresponding octal digit under each of them:

We get the octal representation of the original number: 745.34 8 .

Example 2.27. The number 11101001000,11010010 2 will be converted to hexadecimal number system.

We divide the integer and fractional parts of the number into notebooks, and under each of them we write the corresponding hexadecimal digit:

We get the hexadecimal representation of the original number: 748,D2 16 .

Translation of numbers from number systems with base q=2n to binary. In order to convert an arbitrary number written in a number system with base q=2 n to a binary number system, you need to replace each digit of this number with its n-digit equivalent in the binary number system.

Example 2.28.Let's translate the hexadecimal number 4AC35 16 into the binary number system.

According to the algorithm:

We get: 1001010110000110101 2 .

Tasks for self-fulfillment (Answers)

2.38. Fill in the table, in each line of which the same integer must be written in different number systems.

Binary

octal

Decimal

Hexadecimal

2.39. Fill in the table, in each line of which the same fractional number must be written in different number systems.

Binary

octal

Decimal

Hexadecimal

2.40. Fill in the table, in each line of which the same arbitrary number (the number can contain both an integer and a fractional part) must be written in different number systems.

Binary

octal

Decimal

Hexadecimal

59 B

Write the number in binary notation, and powers of two from right to left. For example, we want to convert the binary number 10011011 2 to decimal. Let's write it down first. Then we write the powers of two from right to left. Let's start with 2 0 , which is equal to "1". We increase the degree by one for each next number. We stop when the number of elements in the list is equal to the number of digits in the binary number. Our example number, 10011011, has eight digits, so a list of eight items would look like this: 128, 64, 32, 16, 8, 4, 2, 1

Write the digits of the binary number under the corresponding powers of two. Now just write 10011011 under 128, 64, 32, 16, 8, 4, 2, and 1 so that each binary digit corresponds to its own power of two. The rightmost "1" of a binary number must match the rightmost "1" of powers of two, and so on. If you're more comfortable, you can write a binary number over powers of two. The most important thing is that they match each other.

Connect the digits in a binary number with the corresponding powers of two. Draw lines (from right to left) that connect each successive digit of the binary number to the power of two above it. Start drawing lines by connecting the first digit of the binary number to the first power of two above it. Then draw a line from the second digit of the binary number to the second power of two. Continue connecting each digit to the corresponding power of two. This will help you visually see the relationship between two different sets of numbers.

Write down the final value of each power of two. Go through each digit of the binary number. If this number is 1, write the appropriate power of two under the number. If this number is 0, write under the number 0.

  • Since "1" corresponds to "1", it remains "1". Since "2" matches "1", it remains "2". Since "4" corresponds to "0", it becomes "0". Since "8" matches "1" it becomes "8", and since "16" matches "1" it becomes "16". "32" matches "0" and becomes "0", "64" matches "0" and therefore becomes "0", while "128" matches "1" and becomes 128.
  • Add up the resulting values. Now add up the numbers below the line. Here's what you should do: 128 + 0 + 0 + 16 + 8 + 0 + 2 + 1 = 155. This is the decimal equivalent of the binary number 10011011.

    Write down the answer together with the subscript equal to the number system. Now all you have to do is write 155 10 to show that you are working with a decimal answer that operates in powers of ten. The more you convert binary to decimal, the easier it will be for you to remember powers of two, and the faster you can complete this task.

  • Use this method to convert a binary number with a decimal point to decimal. You can use this method even if you want to convert a binary number such as 1.1 2 to decimal. All you need to know is that the number on the left side of the decimal is a regular number, and the number on the right side of the decimal is the number of "halves", or 1 x (1/2).

    • "1" to the left of the decimal corresponds to 2 0 , or 1. 1 to the right of the decimal corresponds to 2 -1 , or.5. Add 1 and .5 and you get 1.5, which is the equivalent of 1.1 2 in decimal.
  • Remark 1

    If you want to convert a number from one number system to another, it is more convenient to first convert it to the decimal number system, and only then transfer it from the decimal number system to any other number system.

    Rules for converting numbers from any number system to decimal

    In computer technology using machine arithmetic, the conversion of numbers from one number system to another plays an important role. Below we present the basic rules for such transformations (translations).

      When translating a binary number into a decimal one, it is required to represent the binary number as a polynomial, each element of which is represented as the product of a digit of the number and the corresponding power of the base number, in this case $2$, and then you need to calculate the polynomial according to the rules of decimal arithmetic:

      $X_2=A_n \cdot 2^(n-1) + A_(n-1) \cdot 2^(n-2) + A_(n-2) \cdot 2^(n-3) + ... + A_2 \cdot 2^1 + A_1 \cdot 2^0$

    Figure 1. Table 1

    Example 1

    Convert the number $11110101_2$ to the decimal number system.

    Solution. Using the above table $1$ of degrees of the base $2$, we represent the number as a polynomial:

    $11110101_2 = 1 \cdot 27 + 1 \cdot 26 + 1 \cdot 25 + 1 \cdot 24 + 0 \cdot 23 + 1 \cdot 22 + 0 \cdot 21 + 1 \cdot 20 = 128 + 64 + 32 + 16 + 0 + 4 + 0 + 1 = 245_(10)$

      To convert a number from octal to decimal, you need to represent it as a polynomial, each element of which is represented as the product of a digit of the number and the corresponding power of the base number, in this case $8$, and then you need to calculate the polynomial according to the rules of decimal arithmetic:

      $X_8 = A_n \cdot 8^(n-1) + A_(n-1) \cdot 8^(n-2) + A_(n-2) \cdot 8^(n-3) + ... + A_2 \cdot 8^1 + A_1 \cdot 8^0$

    Figure 2. Table 2

    Example 2

    Convert the number $75013_8$ to the decimal number system.

    Solution. Using the above table $2$ of degrees of base $8$, we represent the number as a polynomial:

    $75013_8 = 7\cdot 8^4 + 5 \cdot 8^3 + 0 \cdot 8^2 + 1 \cdot 8^1 + 3 \cdot 8^0 = 31243_(10)$

      To convert a number from hexadecimal to decimal, you need to represent it as a polynomial, each element of which is represented as the product of a digit of the number and the corresponding power of the base number, in this case $16$, and then you need to calculate the polynomial according to the rules of decimal arithmetic:

      $X_(16) = A_n \cdot 16^(n-1) + A_(n-1) \cdot 16^(n-2) + A_(n-2) \cdot 16^(n-3) + . .. + A_2 \cdot 16^1 + A_1 \cdot 16^0$

    Figure 3. Table 3

    Example 3

    Convert number $FFA2_(16)$ to decimal number system.

    Solution. Using the above table of $3$ base powers of $8$, we represent the number as a polynomial:

    $FFA2_(16) = 15 \cdot 16^3 + 15 \cdot 16^2 + 10 \cdot 16^1 + 2 \cdot 16^0 =61440 + 3840 + 160 + 2 = 65442_(10)$

    Rules for converting numbers from a decimal number system to another

    • To convert a number from decimal to binary, 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 represented as a sequence of the last result of division and the remainder of the division in reverse order.

    Example 4

    Convert the number $22_(10)$ to the binary number system.

    Solution:

    Figure 4

    $22_{10} = 10110_2$

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

    Example 5

    Convert the number $571_(10)$ to octal number system.

    Solution:

    Figure 5

    $571_{10} = 1073_8$

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

    Example 6

    Convert the number $7467_(10)$ to hexadecimal number system.

    Solution:

    Figure 6

    $7467_(10) = 1D2B_(16)$

      In order to convert a proper fraction from a decimal number system to a non-decimal one, it is necessary to multiply the fractional part of the converted number by the base of the system into which it is to be converted. The fraction in the new system will be presented as whole parts of products, starting from the first.

      For example: $0.3125_((10))$ in octal would look like $0.24_((8))$.

      In this case, you may encounter a problem when a finite decimal fraction can correspond to an infinite (periodic) fraction in a non-decimal number system. In this case, the number of digits in the fraction represented in the new system will depend on the required accuracy. It should also be noted that integers remain integers, and proper fractions remain fractions in any number system.

    Rules for converting numbers from a binary number system to another

    • To convert a number from binary to octal, it must be divided into triads (triples of digits), starting with the least significant digit, if necessary, adding zeros to the highest triad, then replacing each triad with the corresponding octal digit according to Table 4.

    Figure 7. Table 4

    Example 7

    Convert the number $1001011_2$ to octal number system.

    Solution. Using table 4, we translate the number from binary to octal:

    $001 001 011_2 = 113_8$

    • To convert a number from binary to hexadecimal, it should be divided into tetrads (four digits), starting with the least significant digit, if necessary, supplementing the senior tetrad with zeros, then each tetrad should be replaced with the corresponding octal digit according to Table 4.

    The calculator allows you to convert whole 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). Numbers must not exceed 30 characters. To enter fractional numbers, use the symbol. or, . To convert a number from one system to another, enter the original number in the first field, the base of the original number system in the second, and the base of the number system to which you want to convert the number in the third field, then click the "Get Entry" button.

    original number recorded 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 -th number system.

    I want to get a record of a 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 -th number system.

    Get an entry

    Completed translations: 1363703

    Number systems

    Number systems are divided into two types: positional And not positional. We use the Arabic system, it is positional, and there is also the Roman one - it is just not positional. In positional systems, the position of a digit in a number uniquely determines the value of that number. This is easy to understand by looking at the example of some number.

    Example 1. Let's take the number 5921 in the decimal number system. We number the number from right to left starting from zero:

    The number 5921 can be written in the following form: 5921 = 5000+900+20+1 = 5 10 3 +9 10 2 +2 10 1 +1 10 0 . The number 10 is a characteristic that defines the number system. The values ​​of the position of the given number are taken as degrees.

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

    The number 1234.567 can be written as follows: 1234.567 = 1000+200+30+4+0.5+0.06+0.007 = 1 10 3 +2 10 2 +3 10 1 +4 10 0 +5 10 -1 + 6 10 -2 +7 10 -3 .

    Converting numbers from one number system to another

    The easiest way to translate a number from one number system to another is to convert the number first to the decimal number system, and then, the result obtained to the required number system.

    Converting numbers from any number system to decimal number system

    To convert a number from any number system to decimal, it is enough to number its digits, starting from zero (the digit to the left of the decimal point) similarly to examples 1 or 2. Let's find the sum of the products of the digits of the number by the base of the number system to the power of the position of this digit:

    1. Convert number 1001101.1101 2 to decimal number system.
    Solution: 10011.1101 2 = 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 = 16+2+1+0.5+0.25+0.0625 = 19.8125 10
    Answer: 10011.1101 2 = 19.8125 10

    2. Convert number E8F.2D 16 to decimal number system.
    Solution: E8F.2D 16 = 14 16 2 +8 16 1 +15 16 0 +2 16 -1 +13 16 -2 = 3584+128+15+0.125+0.05078125 = 3727.17578125 10
    Answer: E8F.2D 16 = 3727.17578125 10

    Converting numbers from a decimal number system to another number system

    To convert numbers from a decimal number system to another number system, the integer and fractional parts of the number must be translated separately.

    Converting the integer part of a number from a decimal number system to another number system

    The integer part is translated from the decimal number system to another number system by successively dividing the integer part of the number by the base of the number system until an integer remainder is obtained, less than the base of the number system. The result of the transfer will be a record from the remains, starting with the last one.

    3. Convert number 273 10 to octal number system.
    Solution: 273 / 8 = 34 and remainder 1, 34 / 8 = 4 and remainder 2, 4 is less than 8, so the calculation is complete. The record from the remnants will look like this: 421
    Examination: 4 8 2 +2 8 1 +1 8 0 = 256+16+1 = 273 = 273 , the result is the same. So the translation is correct.
    Answer: 273 10 = 421 8

    Let's consider the translation of correct decimal fractions into various number systems.

    Converting the fractional part of a number from a decimal number system to another number system

    Recall that a proper decimal fraction is real number with zero integer part. To translate such a number into a number system with base N, you need to consistently multiply the number by N until the fractional part is zeroed or the required number of digits is obtained. If during multiplication a number with an integer part other than zero is obtained, then the integer part is not taken into account further, since it is sequentially entered into the result.

    4. Convert number 0.125 10 to binary number system.
    Solution: 0.125 2 = 0.25 (0 is the integer part, which will be the first digit of the result), 0.25 2 = 0.5 (0 is the second digit of the result), 0.5 2 = 1.0 (1 is the third digit of the result, and since the fractional part is zero , the translation is complete).
    Answer: 0.125 10 = 0.001 2