• Number systems. Transfer from one system to another. Binary numbers, digits and the binary number system. Converting a number to binary from decimal

    Write the number in the binary number system, and the 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 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 corresponds to a different 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 relationship between two different sets of 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 along 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 operates in 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.
  • The positional number system first appeared in ancient Babylon. In India the system works as

    positional decimal numbering using zero, the Indians have this number system

    the Arab nation borrowed, and the Europeans, in turn, took from them. In Europe this system became

    call it Arabic.

    Positional system - the meaning of all digits depends on the position (digit) of a given digit in a number.

    Examples, the standard 10th number system is a positional system. Let's say the number 453 is given.

    The number 4 denotes hundreds and corresponds to the number 400, 5 - the number of tens and corresponds to the value 50,

    and 3 - units and the value 3. It is easy to notice that as the digit increases, the value increases.

    Thus, we write the given number as the sum 400+50+3=453.

    Binary number system.

    There are only 2 digits here - 0 and 1. Base of the binary system- number 2.

    The number located at the very edge to the right indicates the number of units, the second number indicates

    In all digits, only one digit is possible - either zero or one.

    Using the binary number system, it is possible to encode any natural number by representing

    This number is a sequence of zeros and ones.

    Example: 10112 = 1*2 3 + 0*2*2+1*2 1 +1*2 0 =1*8 + 1*2+1=1110

    The binary number system, like the decimal number system, is often used in computing

    technology. The computer stores text and numbers in its memory in binary code and converts it programmatically

    into the image on the screen.

    Adding, subtracting and multiplying binary numbers.

    Addition table in binary number system:

    10 (transfer to

    senior rank)

    Subtraction table in binary number system:

    (loan from senior

    category) 1

    Example of column addition (14 10 + 5 10 = 19 10 or 1110 2 + 101 2 = 10011 2):

    + 1 1 1 0
    1 0 1
    1 0 0 1 1

    Multiplication table in binary number system:

    Example of column multiplication (14 10 * 5 10 = 70 10 or 1110 2 * 101 2 = 1000110 2):

    * 1 1 1 0
    1 0 1
    + 1 1 1 0
    1 1 1 0
    = 1 0 0 0 1 1 0

    Number conversion in the binary number system.

    To convert from binary to decimal use the following table of exponents

    bases 2:

    Starting with the digit one, each digit is multiplied by 2. The dot after 1 is called binary point.

    Convert binary numbers to decimal.

    Let there be a binary number 110001 2. To convert to decimal we write it as a sum by

    ranks as follows:

    1 * 2 5 + 1 * 2 4 + 0 * 2 3 + 0 * 2 2 + 0 * 2 1 + 1 * 2 0 = 49

    A little different:

    1 * 32 + 1 * 16 + 0 * 8 + 0 * 4 + 0 * 2 + 1 * 1 = 49

    It's also good to write the calculation as a table:

    We move from right to left. Under all binary units we write its equivalent in the line below.

    Convert fractional binary numbers to decimal numbers.

    Exercise: convert the number 1011010, 101 2 to the decimal system.

    We write the given number in this form:

    1*2 6 +0*2 5 +1*2 4 +1*2 3 +0 *2 2 + 1 * 2 1 + 0 * 2 0 + 1 * 2 -1 + 0 * 2 -2 + 1 * 2 -3 = 90,625

    Another recording option:

    1*64+0*32+1*16+1*8+0*4+1*2+0*1+1*0,5+0*0,25+1*0,125 = 90,625

    Or in table form:

    0.25

    0.125

    0.125

    Convert decimal numbers to binary.

    Suppose you need to convert the number 19 to binary. We can do it this way:

    19 /2 = 9 with the remainder 1

    9 /2 = 4 with remainder 1

    4 /2 = 2 without a trace 0

    2 /2 = 1 without a trace 0

    1 /2 = 0 with the remainder 1

    That is, each quotient is divided by 2 and the remainder is written to the end of the binary notation. Division

    continues until there is no zero in the quotient. We write the result from right to left. Those. lower

    number (1) will be the leftmost one and so on. So, we have the number 19 in binary notation: 10011.

    Converting fractional decimal numbers to binary.

    When a given number contains an integer part, it is converted separately from the fractional part. Translation

    converting a fractional number from the decimal number system to the binary system occurs as follows:

    • The fraction is multiplied by the base of the binary number system (2);
    • In the resulting product, an entire part is isolated, which is taken as the leading one.

    digit of a number in the binary number system;

    • The algorithm terminates if the fractional part of the resulting product is zero or if

    the required calculation accuracy has been achieved. Otherwise, calculations continue over

    fractional part of the product.

    Example: You need to convert the fractional decimal number 206.116 into a fractional binary number.

    Translating the whole part, we get 206 10 =11001110 2. The fractional part of 0.116 is multiplied by base 2,

    We put the whole parts of the product in the decimal places:

    0,116 . 2 = 0,232

    0,232 . 2 = 0,464

    0,464 . 2 = 0,928

    0,928 . 2 = 1,856

    0,856 . 2 = 1,712

    0,712 . 2 = 1,424

    0,424 . 2 = 0,848

    0,848 . 2 = 1,696

    0,696 . 2 = 1,392

    0,392 . 2 = 0,784

    Result: 206,116 10 ≈ 11001110,0001110110 2

    An algorithm for converting numbers from one number system to another.

    1. From the decimal number system:

    • divide the number by the base of the translated number system;
    • find the remainder when dividing the 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, we find the sum of the products of base 2 by

    appropriate degree of discharge;

    Let's look at one of the most important topics in computer science -. In the school curriculum, it is revealed rather “modestly,” most likely due to the lack of hours allocated to it. Knowledge on this topic, especially on translation of number systems, are a prerequisite for successfully passing the Unified State Exam and admission to universities in the relevant faculties. Below we discuss in detail concepts such as positional and non-positional number systems, examples of these number systems are given, rules are presented for converting whole decimal numbers, proper decimal fractions and mixed decimal numbers to any other number system, converting numbers from any number system to decimal, converting from octal and hexadecimal number systems to the binary number system. There are a lot of problems on this topic in exams. The ability to solve them is one of the requirements for applicants. Coming soon: For each topic of the section, in addition to detailed theoretical material, almost all possible options will be presented tasks for self-study. In addition, you will have the opportunity to download completely free of charge from a file hosting service ready-made detailed solutions to these problems, illustrating various ways to obtain the correct answer.

    positional number systems.

    Non-positional number systems- number systems in which the quantitative value of a digit does not depend on its location in the number.

    Non-positional number systems include, for example, Roman, where instead of numbers there are Latin letters.

    I 1 (one)
    V 5 (five)
    X 10 (ten)
    L 50 (fifty)
    C 100 (one hundred)
    D 500 (five hundred)
    M 1000 (thousand)

    Here the letter V stands for 5 regardless of its location. However, it is worth mentioning that although the Roman number system is a classic example of a non-positional number system, it is not completely non-positional, because The smaller number in front of the larger one is subtracted from it:

    IL 49 (50-1=49)
    VI 6 (5+1=6)
    XXI 21 (10+10+1=21)
    MI 1001 (1000+1=1001)

    positional number systems.

    Positional number systems- number systems in which the quantitative value of a digit depends on its location in the number.

    For example, if we talk about the decimal number system, then in the number 700 the number 7 means “seven hundred”, but the same number in the number 71 means “seven tens”, and in the number 7020 - “seven thousand”.

    Each positional number system has its own base. A natural number greater than or equal to two is chosen as the base. It is equal to the number of digits used in a given number system.

      For example:
    • Binary- positional number system with base 2.
    • Quaternary- positional number system with base 4.
    • Five-fold- positional number system with base 5.
    • Octal- positional number system with base 8.
    • Hexadecimal- positional number system with base 16.

    To successfully solve problems on the topic “Number systems”, the student must know by heart the correspondence of binary, decimal, octal and hexadecimal numbers up to 16 10:

    10 s/s 2 s/s 8 s/s 16 s/s
    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
    16 10000 20 10

    It is useful to know how numbers are obtained in these number systems. You can guess that in octal, hexadecimal, ternary and others positional number systems everything happens in the same way as the decimal system we are used to:

    One is added to the number and a new number is obtained. If the units place becomes equal to the base of the number system, we increase the number of tens by 1, etc.

    This “transition of one” is what frightens most students. In fact, everything is quite simple. The transition occurs if the units digit becomes equal to number base, we increase the number of tens by 1. Many, remembering the good old decimal system, are instantly confused about the digits in this transition, because decimal and, for example, binary tens are different things.

    Hence, resourceful students develop “their own methods” (surprisingly... working) when filling out, for example, truth tables, the first columns (variable values) of which are, in fact, filled with binary numbers in ascending order.

    For example, let's look at getting numbers in octal system: We add 1 to the first number (0), we get 1. Then we add 1 to 1, we get 2, etc. to 7. If we add one to 7, we get a number equal to the base of the number system, i.e. 8. Then you need to increase the tens place by one (we get the octal ten - 10). Next, obviously, are the numbers 11, 12, 13, 14, 15, 16, 17, 20, ..., 27, 30, ..., 77, 100, 101...

    Rules for converting from one number system to another.

    1 Converting integer decimal numbers to any other number system.

    The number must be divided by new number system base. The first remainder of the division is the first minor digit of the new number. If the quotient of the division is less than or equal to the new base, then it (the quotient) must be divided again by the new base. The division must be continued until we get a quotient less than the new base. This is the highest digit of the new number (you need to remember that, for example, in the hexadecimal system, after 9 there are letters, i.e. if the remainder is 11, you need to write it as B).

    Example ("division by corner"): Let's convert the number 173 10 to the octal number system.


    Thus, 173 10 =255 8

    2 Converting regular decimal fractions to any other number system.

    The number must be multiplied by the new number system base. The digit that has become the integer part is the highest digit of the fractional part of the new number. to obtain the next digit, the fractional part of the resulting product must again be multiplied by a new base of the number system until the transition to the whole part occurs. We continue multiplication until the fractional part becomes zero, or until we reach the accuracy specified in the problem (“... calculate with an accuracy of, for example, two decimal places”).

    Example: Let's convert the number 0.65625 10 to the octal number system.

    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 computing technology that uses machine arithmetic, the conversion of numbers from one number system to another plays an important role. Below we give the basic rules for such transformations (translations).

      When converting a binary number to a decimal, you need 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 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 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 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.

    The phrase that everything new is nothing more than the well-forgotten old fully applies to It turns out that even in ancient China they already used something reminiscent of our “one and zero”, although not for arithmetic, but for writing texts of the book of Changes. The Incas were the closest to understanding different number systems: they used both decimal and binary systems, although the latter only for text and coded messages. It can be assumed that even then, 4 thousand years ago, the Incas knew how to convert from the binary to the decimal system.

    The modern version was proposed by Leibniz only about 300 years ago, and after another century and a half he left his name in the memory of posterity with his work on the algebra of logic. Binary arithmetic, together with the algebra of logic, became the foundation of modern digital technology. It all started in 1937, when a method of symbolic analysis of relay and switching circuits was proposed. This work by Claude Chenon became the “mother” for the relay computer, which performed binary addition already in 1937. And, of course, one of the tasks of this “great-grandfather” of modern computers was the conversion from binary to decimal system.

    Only three years passed and the next model of a relay “computer” sent commands to the calculator using a telephone line and a teletype - well, just the ancient Internet in action.

    What are binary, decimal, hexadecimal and, generally speaking, any N-ary system? Nothing complicated. Let's take a three-digit number in our favorite decimal system; it is represented using 10 signs - from 0 to 9, taking into account their location. Let's determine that the digits of this number are in positions 0, 1, 2 (the order goes from the last digit to the first). Each position can contain any of the numbers in the system, but the size of this number is determined not only by its outline, but also by its location. For example, for the number 365 (respectively, position 0 is the number 5, position 1 is the number 6, and position 2 is the number 3) the value of the number at the zero position is simply 5, at the first position - 6*10, and at the second - 3* 10*10. It is interesting here that starting from the first position, the number contains a significant digit (from 0 to 9) and the base of the system to a power equal to the position number, i.e. we can write that 345 = 3*10*10 + 6*10 +3 = 3*102 + 6*101 + 5*100.

    Another example:

    260974 = 2*105 + 6*104 + 0*103 + 9*102 + 7*101 + 4*100.

    As we can see, each positional place contains a significant number from the set of a given system, and a multiplier from the base of the system to a power equal to the position of the given number (the digit capacity of a number is the number of positions, but +1 more).

    From the point of view of representing a number, its binary form is puzzling in its simplicity - there are only 2 numbers in the system - 0 and 1. But the beauty of mathematics is that even in a truncated form, as it may seem, binary numbers are as full and equal as their more "tall comrades". But how can they be compared, for example, with a decimal number? Alternatively, you need to do, and slowly, a conversion from binary to decimal. The task cannot be called difficult, but this painstaking work requires attention. So let's begin.

    Based on what was said above about the order of representation of numbers in any system, and bearing in mind the simplest of them - binary, let’s take any sequence of “ones and zeros”. Let's call this number VO (VO in Russian), and let's try to find out what it is - converting from binary to decimal system. Let it be VO=11001010010. At first glance, the number is just a number. Let's see!

    In the first line we will arrange the number itself in an extended form, and write the second as the sum of each position in the form of factors - a significant figure (here the choice is small - 0 or 1) and the number 2 to the power equal to the positional number in the decimal system, we do the translation from binary to decimal. Now the second line just needs to do the calculations. For clarity, you can also add a third line with intermediate calculations.

    VO = 1 1 0 0 1 0 1 0 0 1 0;

    VO = 1*210 + 1*29 + 0*28 + 0*27 + 1*26 + 0*25 + 1*24 + 0*23 + 0*22 + 1*21 + 0*20;

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

    We calculate the “arithmetic” in the third line and we have what we were looking for: VO = 1618. So, what’s so great about that? And the fact that this number is the most famous of all that are known to people: the proportions of the Egyptian pyramids, the famous Mona Lisa, musical notes and the human body are associated with it, but... But with a little clarification - knowing that there should be a lot of good, His Majesty is a case gave us this number 1000 times larger than the real value - 1.618. Probably so that everyone can enjoy it. And along the way, the translation from the binary system to the decimal system helped to “catch” the most remarkable thing from the endless sea of ​​​​numbers - it is also called the “golden proportion”.