How to quickly convert from binary to decimal. Ordinal counting in various number systems


To quickly convert numbers from the decimal number system to the binary system, you need to have a good knowledge of the numbers “2 to the power”. For example, 2 10 =1024, etc. This will allow you to solve some translation examples literally in seconds. One of these tasks is Problem A1 from the USE demo 2012. You can, of course, take a long and tedious time to divide a number by “2”. But it’s better to decide differently, saving valuable time on the exam.

The method is very simple. Its gist is this: If the number that needs to be converted from the decimal system is equal to the number "2 to the power", then this number in the binary system contains a number of zeros equal to the power. We add a “1” in front of these zeros.

  • Let's convert the number 2 from the decimal system. 2=2 1 . Therefore, in the binary system, a number contains 1 zero. We put “1” in front and get 10 2.
  • Let's convert 4 from the decimal system. 4=2 2 . Therefore, in the binary system, a number contains 2 zeros. We put “1” in front and get 100 2.
  • Let's convert 8 from the decimal system. 8=2 3 . Therefore, in the binary system, a number contains 3 zeros. We put “1” in front and get 1000 2.


Similarly for other numbers "2 to the power".

If the number that needs to be converted is less than the number “2 to the power” by 1, then in the binary system this number consists only of units, the number of which is equal to the power.

  • Let's convert 3 from the decimal system. 3=2 2 -1. Therefore, in the binary system, a number contains 2 ones. We get 11 2.
  • Let's convert 7 from the decimal system. 7=2 3 -1. Therefore, in the binary system, a number contains 3 ones. We get 111 2.

In the figure, the squares indicate the binary representation of the number, and the decimal representation in pink on the left.


The translation is similar for other numbers “2 to the power-1”.

It is clear that the translation of numbers from 0 to 8 can be done quickly or by division, or simply know by heart their representation in the binary system. I gave these examples so that you understand the principle this method and used it to translate more "impressive numbers", for example, to translate the numbers 127,128, 255, 256, 511, 512, etc.

You can encounter problems where you need to convert a number that is not equal to the number “2 to the power”, but close to it. It may be greater or less than 2 to the power. The difference between the translated number and the number "2 to the power" should be small. For example, up to 3. The representation of numbers from 0 to 3 in the binary system just needs to be known without translation.

If the number is greater than , then we solve it like this:

First we convert the number “2 to the power” into the binary system. And then we add to it the difference between the number “2 to the power” and the number being translated.

For example, let's convert 19 from the decimal system. It is greater than the number "2 to the power" by 3.

16=2 4 . 16 10 =10000 2 .

3 10 =11 2 .

19 10 =10000 2 +11 2 =10011 2 .

If the number is less than the number "2 to the power", then it is more convenient to use the number "2 to the power-1". We solve it like this:

First we convert the number “2 to the power-1” into the binary system. And then we subtract from it the difference between the number “2 to the power of 1” and the number being translated.

For example, let's convert 29 from the decimal system. It is greater than the number “2 to the power-1” by 2. 29=31-2.

31 10 =11111 2 .

2 10 =10 2 .

29 10 =11111 2 -10 2 =11101 2

If the difference between the number being translated and the number "2 to the power" is more than three, then you can break the number into its components, convert each part into the binary system and add.

For example, convert the number 528 from the decimal system. 528=512+16. We translate 512 and 16 separately.
512=2 9 . 512 10 =1000000000 2 .
16=2 4 . 16 10 =10000 2 .
Now let's add it in a column:

The positional number system first appeared in ancient Babylon. In India the system works as

positional decimal numbering using zero, among Indians this system numbers

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 the given digit in the 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 decimal number system, often used in computing

technology. The computer stores text and numbers in its memory in binary code And programmatically transforms

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 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.

Conversion fractional binary numbers to decimal.

Exercise: convert the number 1011010, 101 2 to 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

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 received work a whole part is allocated, which is accepted as the senior

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;

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. Closest to understanding different systems The Incas were notationists: 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 the current 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 that performed binary addition already in 1937. And, of course, one of the tasks of this “great-grandfather” modern computers There was a conversion from binary to decimal system.

Only three years passed and the next model of a relay “computer” sent commands to the calculator using telephone line and 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 the power of an equal position 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 (in Russian VO), 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 place the number itself in an expanded form, and write the second as the sum of each position in the form of factors - 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, but we are converting 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 conversion 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”.

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 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$. Represent a number in the binary system as a sequence last result division and 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 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. 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.






2024 gtavrl.ru.