Convert numbers to binary number system. Converting numbers from decimal to binary and back


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 the binary number 1010110. The units in it are in second, third, fifth and seventh places. 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 - by 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.

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, each 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 conversion to 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.

Consider a decimal number to binary system by sequential division by 2. To convert a decimal number 25 into the code, you need to divide it by 2 until 0 remains. The remainders obtained at each division step are written in a line from right to left, after writing the digit of the last remainder this will be the final

The result has already been received!

Number systems

There are positional and non-positional number systems. The Arabic number system that we use in Everyday life, is positional, but Roman is not. In positional number systems, the position of a number uniquely determines the magnitude of the number. Let's consider this using the example of the number 6372 in the decimal number system. Let's number this number from right to left starting from zero:

Then the number 6372 can be represented as follows:

6372=6000+300+70+2 =6·10 3 +3·10 2 +7·10 1 +2·10 0 .

The number 10 determines the number system (in this case it is 10). The values ​​of the position of a given number are taken as powers.

Consider the real decimal number 1287.923. Let's number it starting from zero position of the number from the decimal point to the left and right:

Then the number 1287.923 can be represented as:

1287.923 =1000+200+80 +7+0.9+0.02+0.003 = 1·10 3 +2·10 2 +8·10 1 +7·10 0 +9·10 -1 +2·10 -2 +3· 10 -3.

IN general case the formula can be represented as follows:

C n s n +C n-1 · s n-1 +...+C 1 · s 1 +C 0 ·s 0 +D -1 ·s -1 +D -2 ·s -2 +...+D -k ·s -k

where C n is an integer in position n, D -k - fractional number in position (-k), s- number system.

A few words about number systems. A number in the decimal number system consists of many digits (0,1,2,3,4,5,6,7,8,9), in the octal number system it consists of many digits (0,1, 2,3,4,5,6,7), in the binary number system - from a set of digits (0,1), in the hexadecimal number system - from a set of digits (0,1,2,3,4,5,6, 7,8,9,A,B,C,D,E,F), where A,B,C,D,E,F correspond to the numbers 10,11,12,13,14,15. In the table Tab.1 numbers are presented in different systems Reckoning.

Table 1
Notation
10 2 8 16
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

Converting numbers from one number system to another

To convert numbers from one number system to another, the easiest way is to first convert the number to the decimal number system, and then, from decimal system convert numbers to the required number system.

Converting numbers from any number system to the decimal number system

Using formula (1), you can convert numbers from any number system to the decimal number system.

Example 1. Convert the number 1011101.001 from binary number system (SS) to decimal SS. Solution:

1 ·2 6 +0 ·2 5 + 1 ·2 4 + 1 ·2 3 + 1 ·2 2 + 0 ·2 1 + 1 ·2 0 + 0 ·2 -1 + 0 ·2 -2 + 1 ·2 -3 =64+16+8+4+1+1/8=93.125

Example2. Convert the number 1011101.001 from octal number system (SS) to decimal SS. Solution:

Example 3 . Convert the number AB572.CDF from hexadecimal number system to decimal SS. Solution:

Here A-replaced by 10, B- at 11, C- at 12, F- by 15.

Converting numbers from the decimal number system to another number system

To convert numbers from the decimal number system to another number system, you need to convert the integer part of the number and the fractional part of the number separately.

The integer part of a number is converted from decimal SS to another number system by sequentially dividing the integer part of the number by the base of the number system (for binary SS - by 2, for 8-ary SS - by 8, for 16-ary SS - by 16, etc. ) until a whole residue is obtained, less than the base CC.

Example 4 . Let's convert the number 159 from decimal SS to binary SS:

159 2
158 79 2
1 78 39 2
1 38 19 2
1 18 9 2
1 8 4 2
1 4 2 2
0 2 1
0

As can be seen from Fig. 1, the number 159 when divided by 2 gives the quotient 79 and remainder 1. Further, the number 79 when divided by 2 gives the quotient 39 and remainder 1, etc. As a result, constructing a number from division remainders (from right to left), we obtain a number in binary SS: 10011111 . Therefore we can write:

159 10 =10011111 2 .

Example 5 . Let's convert the number 615 from decimal SS to octal SS.

615 8
608 76 8
7 72 9 8
4 8 1
1

When converting a number from a decimal SS to an octal SS, you need to sequentially divide the number by 8 until you get an integer remainder less than 8. As a result, constructing a number from division remainders (from right to left) we get a number in octal SS: 1147 (See Fig. 2). Therefore we can write:

615 10 =1147 8 .

Example 6 . Let's convert the number 19673 from the decimal number system to hexadecimal SS.

19673 16
19664 1229 16
9 1216 76 16
13 64 4
12

As can be seen from Figure 3, by successively dividing the number 19673 by 16, the remainders are 4, 12, 13, 9. In the hexadecimal number system, the number 12 corresponds to C, the number 13 to D. Therefore, our hexadecimal number is 4CD9.

To convert regular decimal fractions (a real number with a zero integer part) to a number system with base s, you need given number successively multiply by s until the fractional part is pure zero, or we obtain the required number of digits. If, during multiplication, a number with an integer part other than zero is obtained, then this integer part is not taken into account (they are sequentially included in the result).

Let's look at the above with examples.

Example 7 . Let's convert the number 0.214 from the decimal number system to binary SS.

0.214
x 2
0 0.428
x 2
0 0.856
x 2
1 0.712
x 2
1 0.424
x 2
0 0.848
x 2
1 0.696
x 2
1 0.392

As can be seen from Fig. 4, the number 0.214 is sequentially multiplied by 2. If the result of multiplication is a number with an integer part other than zero, then the integer part is written separately (to the left of the number), and the number is written with a zero integer part. If the multiplication results in a number with a zero integer part, then a zero is written to the left of it. The multiplication process continues until the fractional part reaches a pure zero or we obtain the required number of digits. Writing bold numbers (Fig. 4) from top to bottom we get the required number in the binary number system: 0. 0011011 .

Therefore we can write:

0.214 10 =0.0011011 2 .

Example 8 . Let's convert the number 0.125 from the decimal number system to binary SS.

0.125
x 2
0 0.25
x 2
0 0.5
x 2
1 0.0

To convert the number 0.125 from decimal SS to binary, this number is sequentially multiplied by 2. In the third stage, the result is 0. Consequently, the following result is obtained:

0.125 10 =0.001 2 .

Example 9 . Let's convert the number 0.214 from the decimal number system to hexadecimal SS.

0.214
x 16
3 0.424
x 16
6 0.784
x 16
12 0.544
x 16
8 0.704
x 16
11 0.264
x 16
4 0.224

Following examples 4 and 5, we get the numbers 3, 6, 12, 8, 11, 4. But in hexadecimal SS, the numbers 12 and 11 correspond to the numbers C and B. Therefore, we have:

0.214 10 =0.36C8B4 16 .

Example 10 . Let's convert the number 0.512 from the decimal number system to octal SS.

0.512
x 8
4 0.096
x 8
0 0.768
x 8
6 0.144
x 8
1 0.152
x 8
1 0.216
x 8
1 0.728

Got:

0.512 10 =0.406111 8 .

Example 11 . Let's convert the number 159.125 from the decimal number system to binary SS. To do this, we translate separately the integer part of the number (Example 4) and the fractional part of the number (Example 8). Further combining these results we get:

159.125 10 =10011111.001 2 .

Example 12 . Let's convert the number 19673.214 from the decimal number system to hexadecimal SS. To do this, we translate separately the integer part of the number (Example 6) and the fractional part of the number (Example 9). Further, combining these results we obtain.

We encounter the binary number system when studying computer disciplines. After all, it is on the basis of this system that the processor and some types of encryption are built. There are special algorithms for writing a decimal number in the binary system and vice versa. If you know the principle of building a system, it will not be difficult to operate in it.

The principle of constructing a system of zeros and ones

The binary number system is built using two digits: zero and one. Why these particular numbers? This is due to the principle of constructing the signals that are used in the processor. At its lowest level, the signal takes only two values: false and true. Therefore, it was customary to denote the absence of a signal, “false,” by zero, and its presence, “true,” by one. This combination is easy to implement technically. Numbers in the binary system are formed in the same way as in the decimal system. When a digit reaches its upper limit, it is reset to zero and a new digit is added. This principle is used to move through a ten in the decimal system. Thus, numbers are made up of combinations of zeros and ones, and this combination is called the “binary number system”.

Recording a number in the system

In decimal

In binary

In decimal

In binary

How to write a binary number as a decimal number?

There are online services that convert numbers into binary and vice versa, but it’s better to be able to do it yourself. When translated, the binary system is denoted by the subscript 2, for example, 101 2. Each number in any system can be represented as a sum of numbers, for example: 1428 = 1000 + 400 + 20 + 8 - in the decimal system. The number is also represented in binary. Let's take an arbitrary number 101 and consider it. It has 3 digits, so we arrange the number in order in this way: 101 2 =1×2 2 +0×2 1 +1×2 0 =4+1=5 10, where the index 10 denotes the decimal system.

How to write a prime number in binary?

It is very easy to convert to the binary number system by dividing the number by two. It is necessary to divide until it is possible to complete it completely. For example, take the number 871. We begin to divide, making sure to write down the remainder:

871:2=435 (remainder 1)

435:2=217 (remainder 1)

217:2=108 (remainder 1)

The answer is written according to the resulting remainders in the direction from end to beginning: 871 10 =101100111 2. You can check the correctness of the calculations using the reverse translation described earlier.

Why do you need to know translation rules?

The binary number system is used in most disciplines related to microprocessor electronics, coding, data transmission and encryption, and in various areas of programming. Knowledge of the basics of translation from any system to binary will help the programmer develop various microcircuits and control the operation of the processor and other similar systems programmatically. The binary number system is also necessary for implementing methods for transmitting data packets over encrypted channels and creating client-server software projects based on them. In a school computer science course, the basics of converting to the binary system and vice versa are the basic material for studying programming in the future and creating simple programs.

The calculator allows you to convert whole and fractional numbers from one number system to another. The base of the number system cannot be less than 2 and more than 36 (10 digits and 26 Latin letters after all). The length of numbers must not exceed 30 characters. To enter fractional numbers, use the symbol. or, . To convert a number from one system to another, enter the original number in the first field, the base of the original number system in the second, and the base of the number system to which you want to convert the number in the third field, then click the "Get Record" button.

Original number written in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 -th number system.

I want to get a number written in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 -th number system.

Get entry

Translations completed: 1363710

Number systems

Number systems are divided into two types: positional And not positional. We use the Arabic system, it is positional, but there is also the Roman system - it is not positional. In positional systems, the position of a digit in a number uniquely determines the value of that number. This is easy to understand by looking at some number as an example.

Example 1. Let's take the number 5921 in the decimal number system. Let's number the number from right to left starting from zero:

The number 5921 can be written in the following form: 5921 = 5000+900+20+1 = 5·10 3 +9·10 2 +2·10 1 +1·10 0 . The number 10 is a characteristic that defines the number system. The values ​​of the position of a given number are taken as powers.

Example 2. Consider the real decimal number 1234.567. Let's number it starting from the zero position of the number from the decimal point to the left and right:

The number 1234.567 can be written in the following form: 1234.567 = 1000+200+30+4+0.5+0.06+0.007 = 1·10 3 +2·10 2 +3·10 1 +4·10 0 +5·10 -1 + 6·10 -2 +7·10 -3 .

Converting numbers from one number system to another

Most in a simple way converting a number from one number system to another is to first convert the number into a decimal number system, and then the resulting result into the required number system.

Converting numbers from any number system to the decimal number system

To convert a number from any number system to decimal, it is enough to number its digits, starting with zero (the digit to the left of the decimal point) similarly to examples 1 or 2. Let's find the sum of the products of the digits of the number by the base of the number system to the power of the position of this digit:

1. Convert the number 1001101.1101 2 to the decimal number system.
Solution: 10011.1101 2 = 1·2 4 +0·2 3 +0·2 2 +1·2 1 +1·2 0 +1·2 -1 +1·2 -2 +0·2 -3 +1·2 - 4 = 16+2+1+0.5+0.25+0.0625 = 19.8125 10
Answer: 10011.1101 2 = 19.8125 10

2. Convert the number E8F.2D 16 to the decimal number system.
Solution: E8F.2D 16 = 14·16 2 +8·16 1 +15·16 0 +2·16 -1 +13·16 -2 = 3584+128+15+0.125+0.05078125 = 3727.17578125 10
Answer: E8F.2D 16 = 3727.17578125 10

Converting numbers from the decimal number system to another number system

To convert numbers from the decimal number system to another number system, the integer and fractional parts of the number must be converted separately.

Converting an integer part of a number from a decimal number system to another number system

An integer part is converted from a decimal number system to another number system by sequentially dividing the integer part of a number by the base of the number system until a whole remainder is obtained that is less than the base of the number system. The result of the translation will be a record of the remainder, starting with the last one.

3. Convert the number 273 10 to the octal number system.
Solution: 273 / 8 = 34 and remainder 1. 34 / 8 = 4 and remainder 2. 4 is less than 8, so the calculation is complete. The record from the balances will look like this: 421
Examination: 4·8 2 +2·8 1 +1·8 0 = 256+16+1 = 273 = 273, the result is the same. This means the translation was done correctly.
Answer: 273 10 = 421 8

Consider the translation of proper decimal fractions into various systems Reckoning.

Converting the fractional part of a number from the decimal number system to another number system

Let us remind you that the correct decimal called real number with zero integer part. To convert such a number to a number system with base N, you need to sequentially multiply the number by N until the fractional part goes to zero or the required number of digits is obtained. If, during multiplication, a number with an integer part other than zero is obtained, then the integer part is not taken into account further, since it is sequentially entered into the result.

4. Convert the number 0.125 10 to the binary number system.
Solution: 0.125·2 = 0.25 (0 is the integer part, which will become the first digit of the result), 0.25·2 = 0.5 (0 is the second digit of the result), 0.5·2 = 1.0 (1 is the third digit of the result, and since the fractional part is zero , then the translation is completed).
Answer: 0.125 10 = 0.001 2

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

Editor's Choice
Your Zodiac sign makes up only 50% of your personality. The remaining 50% cannot be known by reading general horoscopes. You need to create an individual...

Description of the white mulberry plant. Composition and calorie content of berries, beneficial properties and expected harm. Delicious recipes and uses...

Like most of his colleagues, Soviet children's writers and poets, Samuil Marshak did not immediately begin writing for children. He was born in 1887...

Breathing exercises using the Strelnikova method help cope with attacks of high blood pressure. Correct execution of exercises -...
About the university Bryansk State University named after academician I.G. Petrovsky is the largest university in the region, with more than 14...
Macroeconomic calendar
Representatives of the arachnid class are creatures that have lived next to humans for many centuries. But this time it turned out...
Why do you dream of wedding shoes? Why do you dream of wedding shoes with heels?