• How to convert a binary number. Number systems. Positional number system binary

    | 6th grade | Planning lessons for the school year | Converting binary numbers to decimal system dead reckoning

    Lesson 5
    Converting binary numbers to decimal number system
    Working with the Calculator application





    Converting integer decimal numbers to binary

    Method 1

    Let's try to represent the number 1409 as the sum of the terms of the second row.

    Let's use the difference method. Let's take the term of the second row closest to the original number, but not exceeding it, and make up the difference:

    1409 - 1024 = 385.

    Let’s take the term of the second row that is closest to the resulting difference, but does not exceed it, and compose the difference:

    385 - 256 = 129.

    Let's make the difference in the same way: 129 - 128 = 1.

    As a result we get:

    1409 = 1024 + 256 + 128 + 1 = 1 1024 + 0 512 + 1 256 + + 1 128 + 0 64 + 0 32 + 0 16 + 0 8 + 0 4 + 0 2 + 1 1.

    We see that each member of the second row can either not be included in the sum or be included in it only once.


    The numbers 1 and 0, by which the terms of the second series are multiplied, also make up the original number 1409, but in its other, binary notation: 10110000001.

    The result is written like this:

    1409 10 = 10110000001 2 .

    We wrote the original number using 0 and 1, in other words, we received the binary code of this number, or represented the number in the binary number system.

    Method 2

    This way to get binary code decimal number is based on recording the remainders from dividing the original number and the resulting quotients by 2, continued until the next quotient is equal to 0.

    Example:


    The first cell of the top line contains the original number, and each subsequent cell contains the result of integer division of the previous number by 2.

    The cells of the bottom row contain the remainders from the division of those in top line numbers by 2.

    The last cell of the bottom row remains empty. The binary code of the original decimal number is obtained by sequentially recording all remainders, starting from the last: 1409 10 = 10110000001 2.

    The first 20 terms of the natural series in the binary number system are written as follows: 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011,1100, 1101,1110,1111, 10000. 10001. 10010. 1. 10100. 

    Converting integers from binary to decimal

    Method 1

    Let there be a number 111101 2. It can be represented like this:

    Method 2

    Let's take the same number 111101 2. Let's convert the unit of the 6th digit (the first one on the left in the number record) into units of the 5th digit, for which we multiply 1 by 2, because the unit of the 6th digit in the binary system contains 2 units of the 5th digit.

    To the received 2 units of the 5th category we add the existing unit of the 5th category. Let's convert these 3 units of the 5th category to the 4th category and add the existing unit of the 4th category: 3 2 + 1 = 7.

    Let's convert 7 units of the 4th category to the 3rd category and add the existing unit of the 3rd category: 7 2 + 1 = 15.

    Let's convert 15 units of the 3rd digit to the 2nd digit: 15 2 = 30. In the original number there are no units in the 2nd digit.

    Let's convert 30 units of the 2nd digit to the 1st digit and add the unit present there: 30 2 + 1 = 61. We found that the original number contains 61 units of the 1st digit.

    It is convenient to arrange written calculations like this:

    You can convert integers from the decimal number system to the binary number system and back using the application Calculator.

    Let's do a little experiment .

    1. Launch the Calculator application and run the command [View-Engineering]. Please note a group of switches that define the number system:

    2. Make sure the Calculator is configured to work in decimal number system. Using the keyboard or mouse, enter an arbitrary two-digit number in the input field. Activate the switch Bin and watch the changes in the input window. Return to the decimal number system. Clear the input field.

    3. Repeat step 2 several times for other decimal numbers.

    4. Set up the Calculator to work in the binary number system. Pay attention to which buttons Calculator and the number keys of the keyboard are available to you. Enter one by one binary codes 5th, 10th and 15th terms of the natural series and using a switch Dec convert them to the decimal number system.

    Instructions

    Video on the topic

    In the counting system that we use every day, there are ten digits - from zero to nine. That's why it's called decimal. However, in technical calculations, especially those related to computers, other systems, specifically binary and hexadecimal. Therefore you need to be able to translate numbers from one systems counting to another.

    You will need

    • - a piece of paper;
    • - pencil or pen;
    • - calculator.

    Instructions

    The binary system is the simplest. It has only two digits - zero and one. Each digit of binary numbers, starting from the end, corresponds to a power of two. Two in equals one, in the first - two, in the second - four, in the third - eight, and so on.

    Suppose you are given binary number 1010110. Units in it are in second, third, fifth and seventh places from the end. Therefore, in the decimal system this number is 2^1 + 2^2 + 2^4 + 2^6 = 2 + 4 + 16 + 64 = 86.

    Inverse problem - decimal numbers system. Let's say you have the number 57. To get it, you must sequentially divide the number by 2 and write the remainder. The binary number will be built from end to beginning.
    The first step will give you the last digit: 57/2 = 28 (remainder 1).
    Then you get the second one from the end: 28/2 = 14 (remainder 0).
    Further steps: 14/2 = 7 (remainder 0);
    7/2 = 3 (remainder 1);
    3/2 = 1 (remainder 1);
    1/2 = 0 (remainder 1).
    This is the last step because the result of division is zero. As a result, you got the binary number 111001.
    Check your answer: 111001 = 2^0 + 2^3 + 2^4 + 2^5 = 1 + 8 + 16 + 32 = 57.

    The second, used in computer matters, is hexadecimal. It has not ten, but sixteen digits. So as not to be new symbols, first ten digits of hexadecimal systems are designated by ordinary numbers, and the remaining six are in Latin letters: A, B, C, D, E, F. They correspond to decimal notation numbers m from 10 to 15. To avoid confusion, the number written in hexadecimal is preceded by the # sign or the symbols 0x.

    To make a number from hexadecimal systems, you need to multiply each of its digits by the corresponding power of sixteen and add the results. For example, the number #11A in decimal notation is 10*(16^0) + 1*(16^1) + 1*(16^2) = 10 + 16 + 256 = 282.

    Reverse conversion from decimal systems to hexadecimal is done using the same method of remainders as to binary. For example, take the number 10000. Consistently dividing it by 16 and writing down the remainders, you get:
    10000/16 = 625 (remainder 0).
    625/16 = 39 (remainder 1).
    39/16 = 2 (remainder 7).
    2/16 = 0 (remainder 2).
    The result of the calculation will be the hexadecimal number #2710.
    Check your answer: #2710 = 1*(16^1) + 7*(16^2) + 2*(16^3) = 16 + 1792 + 8192 = 10000.

    Transfer numbers from hexadecimal systems It's much easier to convert to binary. The number 16 is a two: 16 = 2^4. Therefore every hexadecimal digit can be written as a four-digit binary number. If you have less than four digits in a binary number, add leading zeros.
    For example, #1F7E = (0001)(1111)(0111)(1110) = 1111101111110.
    Check the answer: both numbers in decimal notation they are equal to 8062.

    To translate, you need to break the binary number into groups of four digits, starting from the end, and replace each such group with a hexadecimal digit.
    For example, 11000110101001 becomes (0011)(0001)(1010)(1001), which in hexadecimal notation equals #31A9. The correctness of the answer is confirmed by translation into decimal notation: both numbers are equal to 12713.

    Tip 5: How to convert a number to binary

    Due to its limited use of symbols, the binary system is most convenient for use in computers and other digital devices. There are only two symbols: 1 and 0, so this system used in the operation of registers.

    Instructions

    Binary is positional, i.e. The position of each digit in a number corresponds to a certain digit, which is equal to two to the appropriate power. The degree starts at zero and increases as you move from right to left. For example, number 101 is equal to 1*2^0 + 0*2^1 + 1*2^2 = 5.

    Octal, hexadecimal and decimal systems are also widely used among positional systems. And if for the first two the second method is more applicable, then for translation from both are applicable.

    Consider a decimal number to binary system by sequential division by 2. To convert a decimal number 25 V

    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 decimal, you need to represent the binary number in the form 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 octal number system 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 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 the decimal number system to the binary system, 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 the octal number system.

    Solution:

    Figure 5.

    $571_{10} = 1073_8$

    • To convert a number from the decimal number system to 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 translate correct fraction from the decimal number system to the 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. Fraction in new system will be presented in the form of entire parts of works, 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.

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

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

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

    Table 4. Powers of number 2

    n (degree)

    Example.

    2. For translation octal number in decimal it is necessary to write it in the form of a polynomial, consisting of the products of the digits of the number and the corresponding power of the number 8, and calculate it according to the rules of decimal arithmetic:

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

    Table 5. Powers of the number 8

    n (degree)

    Example. Convert the number to the decimal number system.

    3. For translation hexadecimal number in decimal it must be written down as a polynomial, consisting of the products of the digits of the number and the corresponding power of the number 16, and calculated according to the rules of decimal arithmetic:

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

    Table 6. Powers of the number 16

    n (degree)

    Example. Convert the number to the decimal number system.

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

    Example. Convert the number to the binary number system.

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

    Example. Convert the number to the octal number system.

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

    Example. Convert the number to hexadecimal number system.