Translation of numbers in positional number systems. Number systems

Converting numbers in binary, octal, and hexadecimal to decimal is fairly easy. To do this, you need to write down the number in expanded form and calculate its value.

Converting a number from binary to decimal. Let's take any binary number, for example 10.112. Let's write it in expanded form and make calculations:

10.112 = 1* 21 +0*2° + 1*2-1 + 1*2-2 = 1*2 + 0*1 + 1*1/2 + 1*1/4 = 2.7510.

Converting numbers from octal to decimal.

Let's take any octal number, for example 67.58. Let's write it in expanded form and make calculations:

67.58 = 6*81 + 7*8° + 5*8-1 = 6*8 + 7*1 + 5*1/8 = 55.62510.

Converting numbers from hexadecimal to decimal.

Let's take any hexadecimal number, for example 19F16. Let's write it in expanded form (remember that the hexadecimal digit F corresponds to the decimal number 15) and perform the calculations:

19F16 = 1*162 + 9*161 + F*16° = 1*256 + 9*16 + 15*1 = 41510.

Converting numbers from decimal to binary, octal and hexadecimal is more complex and can be done in a variety of ways. Let's consider one of the translation algorithms using the example of converting numbers from the decimal system to the binary system. It should be taken into account that the algorithms for converting integers and proper fractions will differ.

Algorithm for converting integer decimal numbers to the binary number system. Let Acd be an integer decimal number. Let's write it as a sum of powers of base 2 with binary coefficients. In its expanded form there will be no negative powers of the base (numbers 2):

Acd= an-1*2n-1+ an-2*2n-2+…+ a1*21+a0*20

At the first step, we divide the number A by the base of the binary system, that is, by 2. The quotient of the division will be equal to

an-1*2n-2+ an-2*2n-3+…+ a1

At the second step, we again divide the integer quotient by 2, the remainder of the division will now be equal to a0

If we continue this division process, then after the nth step we get the sequence of residues:

a0, a1, ..., an-1

It is easy to see that their sequence coincides with the reverse sequence of digits of an integer binary number written in collapsed form:

A2 = an-1…a1a0

Thus, it is enough to write the remainders in reverse order to obtain the desired binary number.

The algorithm for converting an integer decimal number to binary will be as follows:

Consistently divide the original integer decimal number and the resulting integer quotients by the base of the system (by 2) until you get a quotient that is less than the divisor, that is, less than 2.

Write down the resulting balances in reverse order.

As an example, consider converting the decimal number 19 to binary, recording the results in a table:

As a result, we obtain a binary number: A2 = a 4 a 3a 2a1 a0 = 100112.

Algorithm for converting proper decimal fractions into the binary number system. Let A be a proper decimal fraction. In its expanded form there will be no positive powers of the base (numbers 2):

Add = a-1*2-1+ a-2*2-2

In the first step, we multiply the number Add by the base of the binary system, that is, by 2. The product will be equal to:

a-1 +a-2*2-1+…

The integer part will be equal to a-1

At the second step, we multiply the remaining fractional part by 2 again, we get the integer part equal to a-2

The described process must be continued until, as a result of multiplication, we obtain a zero fractional part or the required calculation accuracy is achieved.

It is easy to notice that the sequence of the resulting numbers coincides with the sequence of digits of a fractional binary number written in collapsed form:

The algorithm for converting a correct decimal fraction to binary will be as follows:

  • 1. Consistently multiply the original decimal fraction and the resulting fractional parts of the products by the base of the system (by 2) until a zero fractional part is obtained or the required calculation accuracy is achieved.
  • 2. Write down the resulting whole parts of the work in direct sequence.

As an example, consider converting the decimal fraction 0.75 to binary, recording the results in a table:


As a result, we obtain a binary fraction: A2 = 0, and -1a-2 = 0.112.

The conversion of numbers from a positional system with an arbitrary base p to a system with a base q is carried out using algorithms similar to those discussed above.

Let's consider the algorithm for converting integers using the example of converting the decimal integer A10 = 42410 into a hexadecimal system, that is, from a number system with base p = 10 to a number system with base q = 16.

In the process of executing the algorithm, it is necessary to pay attention that all actions must be carried out in the original number system (in this case, decimal), and the resulting remainders must be written in digits of the new number system (in this case, hexadecimal).



Let us now consider the algorithm for converting fractional numbers using the example of converting the decimal fraction A10 = 0.625 into the octal system, that is, from a number system with base p = 10 to a number system with base q = 8.

In the process of executing the algorithm, it is necessary to pay attention that all actions must be carried out in the original number system (in this case, decimal), and the resulting remainders must be written in digits of the new number system (in this case, octal).

Converting numbers between number systems whose bases are powers of 2 (q = 2n) can be done using simpler algorithms. Such algorithms can be used to convert numbers between binary (q = 21), octal (q = 23) and hexadecimal (q = 24) number systems.

Converting numbers from binary to octal. To write binary numbers, two digits are used, that is, in each digit of the number, 2 writing options are possible. We solve the exponential equation:

2 = 21. Since 2 is 21, then I = 1 bit.

Each bit of a binary number contains 1 bit of recording option information. Let's solve the exponential equation

8 = 2i. Since 8 = 23, then I = 3 bits. Each variant of an octal number contains 3 bits of information

So, to convert an integer binary number to octal, you need to break it down into groups of three digits, from right to left, and then convert each group to an octal digit. If the last, left, group contains less than three digits, then it must be supplemented on the left with zeros.

Let's convert the binary number 1010012 to octal in this way: 518

To simplify the translation, you can prepare in advance a table for converting binary triads (groups of 3 digits) into octal digits:

will be less than four digits, then you need to pad it on the right with zeros.

Then you need to convert each group into a hexadecimal digit, using a pre-compiled table of correspondence between binary tetrads and hexadecimal digits.

Let's convert the integer binary number A2 = 1010012 to hexadecimal:

To convert a fractional binary number (proper fraction) into octal, you need to break it into triads from left to right and, if the last, right, group contains less than three digits, add zeros to the right. Next, you need to replace triads with octal numbers.

For example, let’s transform the fractional binary number A2 = = 0.1101012 into the octal number system:

We get: A8 = 0.658.

Converting numbers from binary to hexadecimal.

To write hexadecimal numbers, sixteen digits are used, that is, in each digit of the number, 16 writing options are possible. We solve the exponential equation:

16 = 21. Since 16 = 24, then I = 4 bits.

Each digit of a hexadecimal number contains 4 bits of information.

Thus, to convert an integer binary number to hexadecimal, it must be divided into groups of four digits (tetrads), starting from the right, and, if the last left group contains less than four digits, pad it on the left with zeros. To convert a fractional binary number (proper fraction) into hexadecimal, you need to divide it into tetrads from left to right and, if the last right group contains less than 4 digits, then you need to pad it with zeros on the right.

In order to convert any binary number into octal or hexadecimal number systems, it is necessary to carry out conversions using the algorithms discussed above separately for its integer and fractional parts.

To convert numbers from octal and hexadecimal number systems to binary, you need to convert the digits of the number into groups of binary digits. To convert from octal to binary, each digit of a number must be converted into a group of three binary digits (triad), and when converting a hexadecimal number, into a group of four digits (tetrad).

For example, let’s convert the fractional octal number A8 = 0.478 into the binary number system:

In the section on the question how to switch from the decimal number system to the binary one? given by the author Tatyana Tatyana the best answer is Converting decimal numbers to binary

Let's say we need to convert the number 19 to binary. You can use the following procedure:

19 /2 = 9 with remainder 1
9 /2 = 4 with remainder 1
4 /2 = 2 with remainder 0
2 /2 = 1 with remainder 0
1 /2 = 0 with remainder 1

So, we divide each quotient by 2 and write 1 or 0 as the remainder. We must continue the division until there is 1 in the dividend. We put the numbers from the remainder one after another, starting from the end. As a result, we get the number 19 in binary notation (starting from the end): 10011.

Good luck))

Answer from Rosella[guru]

To convert 19 to binary, we select in the top row the largest number that is divisible by 19 without a remainder. In our case, it is 16. (Before 19, 3 more are missing) The next number that is divisible by 3 without a remainder is 2. (1 remains) 1 is divisible by 1 without a remainder. We chose the numbers 16 - 2 - 1. Under them we write “1”, under the rest “0”. We get 10011.
It looks quite cumbersome in words. But if you take a closer look at the table, there is nothing complicated in it. It is quickly remembered and no pen or paper is needed for translation.

The binary number system uses only two digits, 0 and 1. In other words, two is the base of the binary number system. (Similarly, the decimal system has a base of 10.)

To learn to understand numbers in the binary number system, first consider how numbers are formed in the decimal number system familiar to us.

In the decimal number system we have ten digits (from 0 to 9). When the count reaches 9, a new digit (tens) is introduced, the ones are reset to zero and the count starts again. After 19, the tens digit increases by 1, and the ones are reset to zero again. And so on. When the tens reach 9, then the third digit appears - hundreds.

The binary number system is similar to the decimal number system, except that only two digits are involved in the formation of the number: 0 and 1. As soon as the digit reaches its limit (i.e., one), a new digit appears, and the old one is reset to zero.

Let's try to count in binary system:
0 is zero
1 is one (and this is the discharge limit)
10 is two
11 is three (and that's the limit again)
100 is four
101 – five
110 – six
111 – seven, etc.

Converting numbers from binary to decimal

It is not difficult to notice that in the binary number system, the lengths of numbers increase rapidly as the values ​​increase. How to determine what this means: 10001001? Unaccustomed to this form of writing numbers, the human brain usually cannot understand how much it is. It would be nice to be able to convert binary numbers to decimal.

In the decimal number system, any number can be represented as a sum of units, tens, hundreds, etc. For example:

1476 = 1000 + 400 + 70 + 6

1476 = 1 * 10 3 + 4 * 10 2 + 7 * 10 1 + 6 * 10 0

Look at this entry carefully. Here the numbers 1, 4, 7 and 6 are a set of numbers that make up the number 1476. All these numbers are multiplied in turn by ten raised to one degree or another. Ten is the base of the decimal number system. The power to which ten is raised is the digit of the digit minus one.

Any binary number can be expanded in a similar way. Only the base here will be 2:

10001001 = 1*2 7 + 0*2 6 + 0*2 5 + 0*2 4 + 1*2 3 + 0*2 2 + 0*2 1 + 1*2 0

1*2 7 + 0*2 6 + 0*2 5 + 0*2 4 + 1*2 3 + 0*2 2 + 0*2 1 + 1*2 0 = 128 + 0 + 0 + 0 + 8 + 0 + 0 + 1 = 137

Those. The number 10001001 in base 2 is equal to the number 137 in base 10. You can write it like this:

10001001 2 = 137 10

Why is the binary number system so common?

The fact is that the binary number system is the language of computer technology. Each number must be somehow represented on a physical medium. If this is a decimal system, then you will have to create a device that can have ten states. It's complicated. It is easier to produce a physical element that can only be in two states (for example, there is current or no current). This is one of the main reasons why so much attention is paid to the binary number system.

Converting a decimal number to binary

You may need to convert the decimal number to binary. One way is to divide by two and form a binary number from the remainder. For example, you need to get its binary notation from the number 77:

77 / 2 = 38 (1 remainder)
38 / 2 = 19 (0 remainder)
19 / 2 = 9 (1 remainder)
9 / 2 = 4 (1 remainder)
4 / 2 = 2 (0 remainder)
2 / 2 = 1 (0 remainder)
1 / 2 = 0 (1 remainder)

We collect the remainders together, starting from the end: 1001101. This is the number 77 in binary representation. Let's check:

1001101 = 1*2 6 + 0*2 5 + 0*2 4 + 1*2 3 + 1*2 2 + 0*2 1 + 1*2 0 = 64 + 0 + 0 + 8 + 4 + 0 + 1 = 77

Number systems

For the convenience of subsequent conversion, the discrete signal is subjected to coding(for encoding see section Signal coding). Most codes are based on number systems, moreover, using the positional principle of number formation, in which the value of each digit depends on its position in the number.

An example of a positional form of writing numbers is the one we use (the so-called Arabic form of numbers). So, in the numbers 123 and 321, the meaning of the number 3, for example, is determined by its position in the number: in the first case, it means three units (i.e., just three), and in the second, three hundreds (i.e., three hundred).

Then the total number is obtained by the formula:

Where l – number of digits of a number reduced by 1,

i– order of discharge,

m– base of the number system,

a i– a multiplier that takes any integer value from 0 to m-1, and the corresponding number i-th order of number.

For example, for decimal ( m= 10) of the number 345 its full value is calculated by the formula:

3*10 2 + 4*10 1 + 5*10 0 = 345.

Roman numbers are an example of a semi-positional system of number formation: thus, in numbers IX and XI, the sign I denotes in both cases one (a sign of a non-positional system), but, being located to the left of the sign X (denoting ten), is subtracted from ten, and when located to the right – is added to ten. In the first case, the full value of the number is 9, in the second - 11.

In modern computer science, there are mainly three number systems (all positional): binary, hexadecimal and decimal.

Binary number system used to encode a discrete signal, the consumer of which is computer technology. This state of affairs has developed historically, since a binary signal is easier to represent at the hardware level. In this number system, two signs are used to represent numbers - 0 and 1.

Hexadecimal number system used to encode a discrete signal, the consumer of which is a well-trained user - a specialist in the field of computer science. This form represents the contents of any file requested through the integrated operating system shells, for example, using Norton Commander in the case of MS DOS. The characters used to represent the number are decimal digits from 0 to 9 and letters of the Latin alphabet - A, B, C, D, E, F.

Decimal number system is used to encode a discrete signal, the consumer of which is the so-called end user - a non-specialist in the field of computer science (obviously, any person can act as such a consumer). The symbols used to represent a number are numbers from 0 to 9.

To distinguish the number systems in which numbers are represented, additional details are introduced into the designation of binary and hexadecimal numbers:

    for binary numbers - the subscript to the right of the number in the form of the number 2 or the letters B or b (binary), or the sign B or b to the right of the number. For example, 101000 2 = 101000 b = 101000 B = 101000B = 101000b;

    for hexadecimal numbers - the subscript to the right of the number in the form of the number 16 or the letters H or h (hexadecimal - hexadecimal), or the sign H or h to the right of the number. For example, 3AB 16 = 3AB H = 3AB h = 3ABH = 3ABh.

There are certain rules for converting numbers from one number system to another. They differ depending on the format of the number - whole or proper fraction. For real numbers, a combination of the conversion rules for whole number and proper fraction is used

Rules for converting integers

The result of converting an integer Always is an integer.

Conversion from decimal number system to binary and hexadecimal:

a) the original integer is divided by the base of the number system into which it is translated (by 2 - when converting to the binary number system or by 16 - when converting to hexadecimal); the quotient and remainder are obtained;

b) if the resulting quotient is less than the base of the number system into which the conversion is performed, the division process stops, go to step c). Otherwise, the actions described in step a) are performed on the quotient.

c) all received remainders and the last quotient are converted in accordance with the conversion table into numbers of the number system into which the conversion is performed;

d) the resulting number is formed: its highest digit is the last quotient obtained, each subsequent low digit is formed from the resulting division remainders, starting from the last and ending with the first. Thus, the least significant digit of the resulting number is the first remainder of the division, and the highest digit is the last quotient.

Example 1 . Convert the number 19 to the binary number system:

Thus, 19 = 10011 2.

Example 2 . Convert the number 19 to hexadecimal number system:

Thus, 19 = 13 16.

Example 3. Convert the number 123 to hexadecimal number system:

Here the remainder 11 is converted into a hexadecimal digit B) and after that this digit is included in the number. Thus, 123 = 7V 16.

Conversion from binary and hexadecimal number systems to decimal.

In this case, the full value of the number is calculated using a known formula.

Example 4. Convert the number 13 16 to the decimal number system. We have:

13 16 = 1*16 1 + 3*16 0 = 16 + 3 = 19.

Thus, 13 16 = 19.

Example 5. Convert the number 10011 2 to the decimal number system. We have:

10011 2 = 1*2 4 + 0*2 3 + 0*2 2 + 1*2 1 + 1*2 0 = 16+0+0+2+1 = 19.

Thus, 10011 2 = 19.

a) the original number is divided into tetrads (i.e. 4 digits), starting from the least significant digits. If the number of digits of the original binary number is not a multiple of 4, it is padded on the left with insignificant zeros until the multiple of 4 is achieved;

b) each tetrad will be replaced with the corresponding hexadecimal digit in accordance with table.

Binary number

Hexadecimal number

Example 6. Convert the number 10011 2 to hexadecimal number system.

Since the number of digits in the original binary number is not a multiple of 4, we supplement it on the left with insignificant zeros until the number of digits reaches a multiple of 4. We have:

In accordance with table 0011 2 = 11 2 = 3 16 and 0001 2 = 1 2 = 1 16 .

Then 10011 2 = 13 16.

Converting from binary to octal

Similar to the algorithm for converting from binary to hexadecimal, only the original number is divided into triads. Table

Binary number

Hexadecimal number

a) each digit of the original number is replaced by a tetrad of binary digits in accordance with table. If a binary number in the table has less than 4 digits, it is padded on the left with insignificant zeros to the tetrad;

b) insignificant zeros in the resulting number are discarded.

Example 7. Convert the number 13 16 to the binary number system.

By table we have:

    1 16 = 1 2 and after padding with insignificant zeros of the binary number 1 2 = 0001 2;

    3 16 = 11 2 and after padding with insignificant zeros of the binary number 11 2 = 0011 2.

Then 13 16 = 00010011 2. After removing insignificant zeros we have 13 16 = 10011 2.

From octal to binary it is the same.

Rules for converting proper fractions

Recall that a proper fraction has a zero integer part, i.e. its numerator is less than its denominator.

The result of converting a proper fraction Always proper fraction.

Conversion from decimal number system to binary and hexadecimal:

a) the original fraction is multiplied by the base of the number system into which it is converted (2 or 16);

b) in the resulting product, the integer part is converted into a digit of the desired number system and discarded - it is the highest digit of the resulting fraction;

c) the remaining fractional part (this is a proper fraction) is again multiplied by the desired base of the number system, followed by processing the resulting product in accordance with steps a) and b);

d) the multiplication procedure continues until a zero result is obtained in the fractional part of the product or the required number of digits in the result is reached;

e) the required number is formed: the digits sequentially discarded in step b) form the fractional part of the result, and in decreasing order of precedence.

Example 1 . Convert the number 0.847 to the binary number system. Convert to four significant digits after the decimal point.

Thus, 0.847 = 0.1101 2.

In this example, the translation procedure is interrupted at the fourth step because the required number of digits of the result has been received. Obviously, this led to the loss of a number of figures.

Example 2. Convert the number 0.847 to hexadecimal number system. Convert to three significant figures.

In this example, the transfer procedure is also interrupted.

Thus, 0.847 = 0.D8D 16.

Translation from binary and hexadecimal number systems to decimal.

In this case, the full value of the number is calculated by formula, and the coefficients a i take decimal value

Example 3 . Convert from binary number system to decimal number 0.1101 2.

0,1101 2 = 1*2 -1 + 1*2 -2 + 0*2 -3 +1*2 -4 = 0,5 + 0,25 + 0 + 0,0625 = 0,8125.

example 1) is caused by the fact that the conversion procedure to a binary fraction was interrupted.

Thus, 0.1101 2 = 0.8125.

Example 4 . Convert from hexadecimal number system to decimal number 0,D8D 16.

0.D8D 16 = 13*16 -1 + 8*16 -2 + 13*16 -3 = 13*0.0625 + 8*0.003906 + 13* 0.000244 = 0.84692.

The discrepancy between the obtained result and the original number (see. example 2) is caused by the fact that the conversion procedure to hexadecimal fraction was interrupted.

Thus, 0.D8D 16 = 0.84692.

Conversion from binary to hexadecimal:

a) the original fraction is divided into tetrads, starting from the position of the decimal point to the right. If the number of digits of the fractional part of the original binary number is not a multiple of 4, it is padded on the right with insignificant zeros until the multiple of 4 is achieved;

b) each tetrad is replaced with a hexadecimal digit in accordance with table.

Example 5 . Convert from binary number system to hexadecimal number 0.1101 2.

In accordance with table 1101 2 = D 16. Then 0.1101 2 = 0.D 16.

Example 6 . Convert from binary number system to hexadecimal number 0.0010101 2.

Since the number of digits of the fractional part is not a multiple of 4, we add an insignificant zero to the right:

In accordance with table 0010 2 = 10 2 = 2 16 and 1010 2 = A 16.

Then 0.0010101 2 = 0.2A 16.

Conversion from hexadecimal to binary:

a) each digit of the original fraction is replaced by a tetrad of binary digits in accordance with table;

b) insignificant zeros are discarded.

Example 7 . Convert from hexadecimal number system to binary number 0.2A 16.

By table we have 2 16 = 0010 2 and A 16 = 1010 2.

Then 0.2A 16 = 0.00101010 2.

Let's discard the insignificant zero as a result and get the final answer: 0.2A 16 = 0.0010101 2

Rule for converting fractions (irregular fractions)

Recall that an improper fraction has a non-zero fractional part, i.e. its numerator is greater than its denominator.

Improper fraction conversion result Always improper fraction.

When translating, the whole part of the number is translated separately, and the fractional part separately. The results add up.

Example 1 . Convert from decimal number system to hexadecimal number 19.847. Translation is carried out to three significant figures after the decimal point.

Let's imagine the original number as the sum of an integer and a proper fraction:

19,847 = 19 + 0,847.

As follows from example 2 section Integer conversion 19 = 13 16, and in accordance with example 2 section Translation of proper fractions 0.847 = 0.D8D 16.

Then we have:

19 + 0.847 = 13 16 + 0.D8D 16 = 13.D8D 16 .

Thus, 19.847 = 13.D8D 16.

Rules for performing simple arithmetic operations

Arithmetic operations for binary and hexadecimal numbers follow the same rules as for decimal numbers, which are familiar to the reader. Let's look at examples of performing arithmetic operations such as addition, subtraction and multiplication for integers.

Addition rules

The table for adding binary digits looks like this (sum values ​​are highlighted in yellow):

Example 1 . Fold binary numbers 1101 and 11011.

The process of forming the sum by digits is described below:

a) rank 1: 1 2 + 1 2 = 10 2; 0 remains in bit 1, 1 is moved to bit 2;

b) digit 2: 0 2 + 1 2 + 1 2 = 10 2, where the second 1 2 is the carry unit; 0 remains in bit 2, 1 is moved to bit 3;

c) digit 3: 1 2 + 0 2 + 1 2 = 10 2, where the second 1 2 is the carry unit; 0 remains in bit 3, 1 is moved to bit 4;

d) digit 4: 1 2 + 1 2 + 1 2 = 11 2, where the third 1 2 is the carry unit; 1 remains in digit 4, 1 is moved to digit 5;

e) rank 5: 1 2 + 1 2 = 10 2; where the second 1 2 is the transfer unit; 0 remains in bit 5, 1 is moved to bit 6.

Thus: 1 1 0 1 2 +1 1 0 1 1 2 = 10 1 0 0 0 2 .

Let's check the result. To do this, we determine the full values ​​of the terms and sums (see. Integer conversion):

1101 2 = 1*2 3 +1*2 2 + 0*2 1 + 1*2 0 = 8 + 4 + 1 = 13;

11011 2 = 1*2 4 + 1*2 3 + 0*2 2 + 1*2 1 + 1*2 0 = 16 + 8 + 2 + 1 = 27;

101000 2 = 1*2 5 + 0*2 4 + 1*2 3 + 0*2 2 + 0*2 1 + 0*2 0 = 32 + 8 = 40.

Since 13 + 27 = 40, binary addition is correct.

The table for adding some hexadecimal numbers looks like this (the row and column designations correspond to the terms):

Example 2 . Fold hexadecimal numbers 1C and 7B.

Let's write the terms in a column and number the digits, assigning the least significant digit number 1:

The process of generating the result by digits using the given tables described below:

a) category 1: C 16 + B 16 = 17 16; 7 remains in rank 1; 1 is transferred to digit 2;

b) digit 2: 1 16 + 7 16 + 1 16 = 9 16, where the second 1 16 is the carry unit.

Thus: 1 C 16 + 7 B 16 = 9 7 16.

Let's check the result. To do this, we determine the full values ​​of the terms and the result (see. Integer conversion):

1C 16 = 1*16 1 + 12*16 0 = 16 + 12 = 28;

7B 16 = 7*16 1 + 11*16 0 = 112 + 11 = 123;

97 16 = 9*16 1 + 7*16 0 = 144 + 7 = 151.

Since 28 + 123 = 151, the addition is correct.

Subtraction rules

When subtracting, the addition tables given earlier are used.

Example 3 . Subtract from binary numbers 101 binary number 11.

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;



 

It might be useful to read: