• Convert 123 from decimal to binary. Number systems. Transfer from one system to another

    Write the number in the binary number system, and the powers of two from right to left. For example, we want to convert 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 subsequent 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 elements 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 simply write 10011011 under the numbers 128, 64, 32, 16, 8, 4, 2, and 1, so that each binary digit corresponded to its power of two. The rightmost "1" of the binary number must correspond to the rightmost "1" of the powers of two, and so on. If you prefer, you can write the binary number above powers of two. The most important thing is that they match each other.

    Match 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 a 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 number to the corresponding power of two. This will help you visually see the connection between the two various sets numbers.

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

    • Since "1" matches "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 therefore becomes 128.
  • Add up the resulting values. Now add the resulting numbers under the line. Here's what you would do: 128 + 0 + 0 + 16 + 8 + 0 + 2 + 1 = 155. This is the decimal equivalent of the binary number 10011011.

    Write the answer together with a 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, which deals with powers of ten. The more you convert binary numbers to decimals, the easier it will be for you to remember powers of two, and the faster you will be able to complete the task.

  • Use this method to convert a binary number with a decimal point to decimal form. 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 "halve" number, or 1 x (1/2).

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

    If you want to convert a number from one number system to another, then it is more convenient to first convert it to the decimal number system, and only then convert 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, an important role is played by the conversion of numbers from one number system to another. Below we give the basic rules for such transformations (translations).

      When converting a binary number to a decimal, 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 in this case$2$, and then you need to calculate the polynomial using 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 given table of $1$ powers 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 the octal number system to the decimal number system, 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 given table of $2$ powers of the 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 the number $FFA2_(16)$ to the decimal number system.

    Solution. Using the given table of $3$ powers of the base $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 the decimal number system to another

    • To convert a number from decimal system When calculating into binary, it must be sequentially 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 remainders from 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 the decimal number system to octal, it must be sequentially divided by $8$ until there is a remainder less than or equal to $7$. A number in the octal number system is represented as a sequence of digits of the last division result and the remainders from the division in reverse order.

    Example 5

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

    Solution:

    Figure 5.

    $571_{10} = 1073_8$

    • To convert a number from the decimal number system to the hexadecimal system, it must be successively divided by $16$ until there is a remainder less than or equal to $15$. A number in the hexadecimal system is represented as a sequence of digits of the last division result 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 number system, it is necessary to sequentially multiply the fractional part of the number being converted by the base of the system to which it needs to be converted. Fractions in the new system will be represented as whole parts of products, starting with the first.

      For example: $0.3125_((10))$ in octal number system will 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 the 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 the binary number system to octal, it must be divided into triads (triples of digits), starting with the least significant digit, if necessary, adding zeros to the leading triad, then replace each triad with the corresponding octal digit according to Table 4.

    Figure 7. Table 4

    Example 7

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

    Solution. Using Table 4, we convert the number from the binary number system to octal:

    $001 001 011_2 = 113_8$

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

    1. Ordinal counting various systems Reckoning.

    IN modern life we use positioning systems notation, 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 talk only about them, omitting the term “positional”.

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

    Since we have a decimal number system, we have 10 symbols (digits) to construct numbers. We start counting: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The numbers are over. We increase the bit depth of the number and reset the least significant digit: 10. Then we increase the low digit again until all the digits are gone: 11, 12, 13, 14, 15, 16, 17, 18, 19. We increase the high digit by 1 and reset the low digit: 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 (we 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 decimal 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. Conversion from the decimal number system to any other.

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

    Example 1. Let's convert the decimal number 46 to the binary number system.

    Example 2. Let's convert the decimal number 672 to the octal number system.

    Example 3. Let's convert the decimal number 934 to the hexadecimal number system.

    3. Conversion from any number system to decimal.

    In order to learn how to convert numbers from any other system to decimal, let's analyze the usual notation for a decimal number.
    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 powers of the base of the number system. For example, let's take the number 1201 in the ternary number system. Let's number the digits from right to left starting from zero and imagine our number as the sum of the products of a digit and three to the power of the digit of the number:

    This is it decimal notation our number, i.e.

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

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

    4. Conversion from the binary system to the system with the base “power of two” (4, 8, 16, etc.).

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

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

    We learned how to build a correspondence table in step 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.

    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. Conversion from a system with the base “power of two” (4, 8, 16, etc.) to binary.

    This translation is similar to the previous one, made in reverse side: We replace each digit with a group of binary digits from the lookup table.

    Example 7. Let's convert the hexadecimal number C3A6 to the binary number system.

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



    Purpose of the service. The service is designed to convert numbers from one number system to another in online mode. To do this, select the base of the system from which you want to convert the number. You can enter both integers and numbers with commas.

    Number

    Conversion 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 both whole numbers, for example 34, and fractional numbers, for example, 637.333. For fractional numbers, the translation accuracy 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 symbol 0...9, A, B, ..., F. This representation can be designated in different ways, here only the symbol “h” is used after the last hexadecimal digit. For example, A5h. In program texts, the same number can be designated as either 0xA5 or 0A5h, depending on the syntax of the programming language. A leading zero (0) is added to the left of the most significant hexadecimal digit represented by the letter to distinguish between numbers and symbolic names.
    Decimal (decimal) numbers – each byte (word, double word) is represented regular number, and the decimal representation sign (the letter “d”) is usually omitted. The byte in 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 is sometimes necessary.
    Octal (octal) numbers - each triple of bits (division starts from the least significant) is written as a number 0–7, with an “o” at the end. The same number would be written as 245o. The octal system is inconvenient because the byte cannot be divided equally.

    Algorithm for converting numbers from one number system to another

    Translation of integers 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 remains a number less than the base of the new number system. The new number is written as division remainders, starting from the last one.
    Converting a regular 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 achieved. As a result of each multiplication operation, one digit of a new number is formed, starting with the highest one.
    Improper fraction translation is carried out according to rules 1 and 2. The integer and fractional parts are written together, separated by a comma.

    Example No. 1.



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

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

    Example No. 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 the hexadecimal system, you must divide the number into parts of four digits, following the same rules.
    Example No. 3. 1010111010,1011 = 10.1011.1010,1011 = 2B12,13 HEX
    here 0010=2; 1011=B; 1010=12; 1011=13

    Converting numbers from 2, 8 and 16 to the decimal system is done by breaking the number into individual ones and multiplying it by the base of the system (from which the number is translated) raised to the power corresponding to it serial number in the translated number. In this case, the numbers are numbered to the left of the decimal point (the first number is numbered 0) with increasing, and to the right with decreasing (i.e., with a negative sign). The results obtained are added up.

    Example No. 4.
    An example of conversion 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 An 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 conversion 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 converting 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 when dividing an integer part of a number;
      • write down all remainders from division in reverse order;
    2. From the binary number system
      • To convert to the decimal number system, it is necessary to find the sum of the products of base 2 by the corresponding degree of digit;
      • To convert a number to octal, you need to break the number into triads.
        For example, 1000110 = 1,000 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 the systems is expressed in a table.
    Number system correspondence table:
    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 conversion to octal number system