How to convert from binary to decimal. Converting numbers from one number system to another


1. Ordinal counting various systems Reckoning.

In modern life, we use positional number systems, that is, systems in which the number denoted by a digit depends on the position of the digit in the notation of the number. Therefore, in the future we will talk only about them, omitting the term “positional”.

In order to learn how to convert numbers from one system to another, we will understand how sequential recording of numbers occurs using the example of the decimal system.

Since we have a decimal number system, we have 10 symbols (digits) to construct numbers. We start counting: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. The numbers are over. We increase the bit depth of the number and reset the low-order digit: 10. Then we increase the low-order digit again until all the digits are gone: 11, 12, 13, 14, 15, 16, 17, 18, 19. We increase the high-order digit by 1 and reset the low-order digit: 20. When we use all the digits for both digits (we get the number 99), we again increase the digit capacity of the number and reset the existing digits: 100. And so on.

Let's try to do the same in the 2nd, 3rd and 5th systems (we introduce the notation for the 2nd system, for the 3rd, etc.):

0 0 0 0
1 1 1 1
2 10 2 2
3 11 10 3
4 100 11 4
5 101 12 10
6 110 20 11
7 111 21 12
8 1000 22 13
9 1001 100 14
10 1010 101 20
11 1011 102 21
12 1100 110 22
13 1101 111 23
14 1110 112 24
15 1111 120 30

If the number system has a base greater than 10, then we will have to enter additional characters; it is customary to enter letters of the Latin alphabet. For example, for the 12-digit system, in addition to ten digits, we need two letters ( and ):

0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10
11
12 10
13 11
14 12
15 13

2. Conversion from the decimal number system to any other.

To convert a positive integer decimal number to a number system with a different base, you need to divide this number by the base. Divide the resulting quotient by the base again, and further until the quotient is less than the base. As a result, write down in one line the last quotient and all remainders, starting from the last.

Example 1. Let's convert the decimal number 46 to the binary number system.

Example 2. Let's convert the decimal number 672 to the octal number system.

Example 3. Let's convert the decimal number 934 to the hexadecimal number system.

3. Conversion from any number system to decimal.

In order to learn how to convert numbers from any other system to decimal, let's analyze the usual notation for a decimal number.
For example, the decimal number 325 is 5 units, 2 tens and 3 hundreds, i.e.

The situation is exactly the same in other number systems, only we will multiply not by 10, 100, etc., but by the powers of the base of the number system. For example, let's take the number 1201 in the ternary number system. Let's number the digits from right to left starting from zero and imagine our number as the sum of the products of a digit and three to the power of the digit of the number:

This is the decimal notation of our number, i.e.

Example 4. Let's convert to decimal system octal number 511.

Example 5. Let's convert to the decimal number system hexadecimal number 1151.

4. Conversion from the binary system to the system with the base “power of two” (4, 8, 16, etc.).

To convert a binary number to a number with the base “power of two”, it is necessary to divide the binary sequence into groups according to the number of digits equal to the power from right to left and replace each group with the corresponding digit new system Reckoning.

For example, Let's convert the binary number 1100001111010110 to the octal system. To do this, we will divide it into groups of 3 characters starting from the right (since ), and then use the correspondence table and replace each group with a new number:

We learned how to build a correspondence table in step 1.

0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7

Those.

Example 6. Let's convert the binary number 1100001111010110 to hexadecimal.

0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F

5. Conversion from a system with the base “power of two” (4, 8, 16, etc.) to binary.

This translation is similar to the previous one, made in reverse side: We replace each digit with a group of binary digits from the lookup table.

Example 7. Let's convert the hexadecimal number C3A6 to the binary number system.

To do this, replace each digit of the number with a group of 4 digits (since ) from the correspondence table, supplementing the group with zeros at the beginning if necessary:



The most common in modern world calculation methods - decimal and binary. They are used in completely different areas, but both are equally important. Often a conversion from binary to decimal system or vice versa is required. The names come from the bases, which depend on how many signs are used in writing numbers. In binary it is only 0 and 1, and in decimal it is from 0 to 9. In other systems, in addition to numbers, letters, other icons and even hieroglyphs are used, but almost all of them have long been outdated. Since even other types of numerical systems are much less common, we will primarily talk about the two already mentioned. It's actually amazing how all this could have been invented. Let's talk about this topic separately.

History of origin

Even now, when it would seem that the whole world thinks the same, the most different systems. In the most remote corners globe are content with only the concepts of “one”, “two” and “many”, or something similar. What can we say about those times when it was much more difficult for people to contact each other, so it was used great amount a variety of types of records and calculation methods. Humanity did not immediately come to existing system, and this is reflected in the fact that the hour is divided into 60 minutes, and not into 100 periods of time, which would seem to be more logical. And at the same time, people often count in tens rather than dozens. All these are echoes of the time when one’s own fingers or, for example, the phalanges of some of them served as tools for quantifying something. This is how the decimal and duodecimal systems arose. But how did binary arise? Very simple and logical. The fact is that, for example, diodes have only two positions: it can be either on or off. The first state can thus be written as 1, and the second as 0. However, this does not mean that the binary system arose simultaneously with electronic devices. It was used much earlier, for example, Leibniz considered it extremely convenient, elegant and simple. It’s even surprising that this number system did not eventually become the main one.

Areas of application

For most people, the two major number systems simply do not intersect. So converting from binary to decimal is not a feasible task for everyone. The fact is that latest system used in everyday life, communication between people, for simple calculations, etc. But all digital devices, primarily computers, speak the binary language. Any information located in the memory of every desktop PC, tablet, phone, laptop and many other devices is various combinations zeros and ones.

Differences and features

When it comes to number systems, it is imperative to somehow differentiate between them. After all, to distinguish between 11 and 100 different methods recording just like that is completely impossible. That is why the pointer below and to the right of the number itself is used. So, when you see the entry 11 2 or 100 10, you can understand what it’s about we're talking about. Both systems are positional, that is, its value depends on the location of a particular digit. They talk about the digits of the decimal system in school: there are units, tens, hundreds, thousands, etc. In the binary system everything is the same. But due to the fact that its base - 2 - is less than 10, it needs much more digits, that is, the recording of numbers turns out to be much longer. By the way, in binary, as in all other systems except decimal, which is the most common, reading occurs in a special way. If base 10 makes it possible to read 101 as "one hundred and one", then for 2 it will be "one zero one".

Returning to the issue of discharges, it must be repeated that due to a much smaller base, more discharges are required. So, for example, 8 10 is 1000 2. The difference is obvious - one rank and four. Another major difference is that there is no negative numbers. Of course, you can write it down, but it will still be stored and encrypted differently. So, how is the conversion from binary to decimal and vice versa made?

Algorithm

Quite rarely, but still sometimes you have to make a transition from one base to another. In other words, there is a need to convert from binary to decimal and vice versa. Modern computers they do it easily and quickly, even if the recordings are very long and voluminous. Humans can do this too, albeit much more slowly and less efficiently. Carrying out both one and the second operation is not so difficult, but it requires knowledge of how to do it, attentiveness and practice. In order to move from base 2 to 10, you need to do the following steps:

2) sequentially multiply the value by 2, raised to a power equal to the position number;

3) add up the results.

Another way is to start summing the products of digits sequentially from right to left. This is called the Horner transformation and many people find it more convenient than the usual algorithm.

In order to carry out the reverse operation, that is, move from the decimal system to the binary system, you need to do this:

1) divide the original number by 2 and write down the remainder (1 or 0);

2) repeat step 1 until the moment when only 0 or 1 remains;

3) write down the obtained values ​​in order.

There are other ways to convert from binary to decimal number systems and vice versa. But they have no advantage over the described algorithm and are not more efficient. But they require skills in performing arithmetic operations in the binary system, which is available to very few.

Fractions

Fortunately or unfortunately, the fact remains that the binary system uses not only integers. Converting fractions is not a very difficult, but often time-consuming task for humans. If the original number is presented in the decimal system, then after converting the integer, everything after the decimal point should no longer be divided, but multiplied by 2, writing down the integer parts. If you are converting from binary to decimal system, then everything is even simpler. In this case, when the decimal part conversion begins, the power to which 2 is raised will successively be -1, -2, -3, etc. It is best to consider this in practice.

Example

In order to understand how to apply the described algorithms, you need to do all the operations yourself. Practice can always reinforce theory, so it would be best to consider the following examples:

  • converting 1000101 2 to the decimal system: 1x2 6 + 0x2 5 + 0x2 4 + 0x2 3 + 1x2 2 + 0x2 1 + 1x2 0 = 64+0+0+0+4+1 = 69 10 ;
  • using Horner's method. 00110111010 2 = 0x2+0=0x2+0=0x2+1=1x2+1=3x2+0=6x2+1=13x2+1=27x2+1=55x2+0=110x2+1=221x2+0=442 10 ;
  • 1110.01 2: 1x2 3 + 1x2 2 + 1x2 1 + 0x2 0 + 0x2 -1 + 1x2 -2 = 8+4+2+0.25 = 14.25 10 ;
  • from the decimal system: 15 10 = 15/2=7(1)/2=3(1)/2=1(1)/2=0(1)= 1111 2 ;

How not to get confused?

Even using only the binary and decimal systems as an example, it becomes clear that changing the base manually is a non-trivial task. But there are also others: hexadecimal, octal, sexagesimal, etc. When manually converting from one number system to another, care is extremely necessary. It’s really difficult not to get confused, especially if the post is long. In addition, we must not forget that digits are counted from 0, not 1, that is, the number of digits will always be one more. Of course, you need to carefully count the number of digits and not make mistakes in arithmetic operations and, of course, not skip steps in the algorithm. Ultimately, there are ways to transition between bases using software methods. But here it’s easier to write a script yourself than to search for it in the open spaces worldwide network. In any case, manual translation skills, as well as a theoretical understanding of how this is done, should also be present.

For computer chips, only one thing is important. Either there is a signal (1) or there is no signal (0). But writing programs in binary code is not easy. On paper, you get very long combinations of zeros and ones. It's hard for a person.

Using the familiar decimal system in computer documentation and programming is very inconvenient. Conversions from binary to decimal systems and vice versa are very labor-intensive processes.

The origin of the octal system, as well as the decimal system, is associated with counting on fingers. But it is not the fingers that need to be counted, but the spaces between them. There are just eight of them.

The solution to the problem was octal. By at least at dawn computer equipment. When the processor capacity was small. The octal system made it easy to convert both binary numbers into octal and vice versa.

The octal number system is a number system with a base of 8. It uses the numbers from 0 to 7 to represent numbers.

Conversion

To convert a number to binary, you need to replace each digit octal number for three out binary digits. It is only important to remember which binary combination corresponds to the digits of the number. There are very few of them. Only eight!
In all number systems, except decimal, the digits are read one at a time. For example, in octal system The number 610 is pronounced "six, one, zero."

Video on the topic

The components of electronic machines, which include computers, have only two distinguishable states: there is current and there is no current. They are designated "1" and "0" respectively. Since there are only two such states, many processes and operations in electronics can be described using binary numbers.

Instructions

Divide the decimal number by two until you get a remainder indivisible by two. At the step we get the remainder 1 (if the number was odd) or 0 (if the dividend is divisible by two without a remainder). All these balances must be taken into account. The last quotient obtained as a result of such step-by-step division will always be one.
We write the last unit in the most significant digit of the desired binary, and write the remainders obtained in the process after this unit in reverse order. Here you need to be careful and not skip zeros.
Thus, the number 235 in binary code will correspond to the number 11101011.

Now let's convert the fractional part of the decimal number into the binary number system. To do this, we sequentially multiply the fractional part of the number by 2 and fix the integers of the resulting numbers. We add these integer parts to the number obtained in the previous step after the binary one in direct order.
Then decimal fractional number 235.62 corresponds to the binary fraction 11101011.100111.

Video on the topic

note

Binary fraction number will be finite only if the fractional part of the original number is finite and ends in 5. The simplest case: 0.5 x 2 = 1, therefore 0.5 in decimal is 0.1 in binary.

Sources:

  • Converting decimal numbers to binary in 2019

Tip 4: How to convert binary numbers to decimal

The binary or binary number system is used to display electronic information. Any number can be written in binary form. The binary system is used in all computers. Each entry in them is encoded according to certain rules using a set of two characters: 0 and 1. You can convert a binary number into its decimal representation, which is more convenient for the user, using the developed algorithm.

Instructions

Imagine the number as powers of 2. To do this, all eight digits are sequentially multiplied by the number 2 raised to . The degree must correspond to the digit category. The digit is counted from zero, starting from the least significant, rightmost symbol of the binary numbers. Write all eight composed works in .

Tip 5: How to write a decimal number in the binary number system

Decimal system dead reckoning– one of the most common in mathematical theory. However, with the advent information technologies, the binary system is no less widespread, since it is the main way of representing information in computer memory.

Instructions

Conversion from decimal to binary is implemented for both integers and fractions. The translation of an integer decimal number is carried out by sequentially dividing it by 2. In this case, the number of iterations (actions) increases until the quotient becomes zero, and the final binary number is written as the resulting residues from right to left.

For example, the transformation of the number 19 looks like this: 19/2 = 18/2 + 1 = 9, the remainder is 1, we write 1;9/2 = 8/2 + 1 = 4, the remainder is 1, we write 1;4/ 2 = 2, there is no remainder, we write 0;2/2 = 1, there is no remainder, we write 0;1/2 = 0 + 1, the remainder is 1, we write 1. So, after the method of sequential division to the number 19 we got binary number 10011.

The shortest number system is binary. She is completely based on positional form recording numbers. The main characteristic is the principle doubling digits when performing a transition from a certain position to the next. From one number system to another, you can convert using special program, and manually.

In contact with

Historical recognition

The appearance of binary SS in history is associated with the scientist mathematician V.G. Leibniz. It was he who first spoke about the rules for performing operations with numerical values of this kind. But initially this principle remained unclaimed. The algorithm received worldwide recognition and application at the dawn of computers.

Convenience and simplicity operations have led to the need for more detailed study this subsection of arithmetic, which became indispensable in the development computer technology With software. For the first time, such mechanisms appeared on the German and French markets.

Attention! A specific point about the superiority of the binary system in relation to the decimal system, precisely in this industry, was set in 1946 and substantiated in an article by A. Bex, H. Goldstein and J. Von Neumann.

Converting a number from the decimal number system to binary.

Features of binary arithmetic

All binary CC is based on the application of only two characters, which very closely match the features digital circuit. Each of the symbols is responsible for a specific action, which often implies two states:

  • the presence or absence of a hole, for example, a punched card or paper tape;
  • on magnetic media is responsible for the state of magnetization or demagnetization;
  • by signal level, high or low.

In the science in which SS is used, a certain terminology has been introduced, its essence is as follows:

  • Bit – binary digit, which consists of two components that carry a certain meaning. Placed on the left is defined as the senior one and is a priority, and on the right is the junior one, which is less significant.
  • A byte is a unit that consists of eight bits.

Many modules perceive and process information in portions or words. Every word has different weight and may consist of 8, 16 or 32 bits.

Rules for transfers from one system to another

One of the most important factors machine arithmetic is transfer from one SS to another. Therefore, let us pay attention to the basic algorithms for performing a process that will show how to convert a number to the binary system.

Converting the decimal system to binary

First, let us turn to the question of how to convert the system from decimal to binary number system. For this there is translation rule from decimal numbers to binary code, which implies mathematical operations.

Requires a number written in decimal form divide by 2. Continue dividing until there are no more quotients left. unit. If a binary number system is required, the translation is carried out as follows:

186:2=93 (remaining 0)

93:2=46 (rest 1)

46:2=23 (rest. 0)

23:2=11 (rest 1)

11:2=5 (remaining 1)

5:2=2 (rest.1)

After the division process is completed, then write one in the quotient and write all the remainders sequentially in reverse order of division. That is, 18610=1111010. The rule for converting decimal numbers to SS must always be followed.

Converting a number from the decimal system to binary.

Converting from decimal SS to octal

A similar process is followed when converting from decimal SS to octal. It is also called " substitution rule" If in the previous example the data was divided by 2, then here it is necessary divide by 8. The algorithm for converting the number X10 to octal consists of the following steps:

  1. The number X10 begins to be divided by 8. We take the resulting quotient for the next division, and the remainder is written as least significant bit.
  2. We continue dividing until we get the result of the quotient equal zero or remainder, which in its value less than eight. In this case, we write all the remainders as low order bits.

For example, you need to convert the number 160110 to octal.

1601:8=200 (remaining 1)

200:8=25 (remaining 0)

25:8=3 (rest.1)

So, we get: 161010=31018.

Converting from decimal to octal.

Write a decimal number in hexadecimal

Conversion from decimal to hexadecimal SS is carried out similarly using the substitution system. But in addition to numbers, they also use letters of the latin alphabet A, B, C, D, E, F. Where A represents remainder 10 and F represents remainder 15. Decimal number divided by 16. For example, convert 10710 to hexadecimal:

107:16=6 (remaining 11 – replace B)

6 is less than sixteen. We stop dividing and write 10710 = 6B16.

Moving from another system to binary

The next question is how to convert a number from octal to binary. Converting numbers from any system to binary is quite simple. An assistant in this matter is table for number systems.

Most people on our planet use the decimal number system when counting, but computers use the binary number system. Some tribes at the dawn of human development used duodecimal and sexagesimal. It is from them that we are left with 12 hours on the dial and 60 minutes in an hour.

Sometimes it is necessary to convert a number from one system to another. In this article, we will look more specifically at how to convert to the decimal system from some other popular systems.

The principle of constructing a number from digits

First of all, you need to understand what a number system is and its basis. A number system is a way of representing numbers as a combination of certain digits. The basis of the system is the number of digits used in it. For example, in the decimal system with base 10 there are only 10 digits - from 0 to 9. In hexadecimal, there are, respectively, 16 digits, which are designated by Arabic numerals 0 - 9 and letters A - F instead of numbers 10 - 15. For example, 2F7BE 16 is a hexadecimal number. When written in this way, the subscript denotes the base of the number system. The key difference between systems with different bases is the "value" of the number 10. In hexadecimal system 10 16 is equal to 16 10, but in binary 10 2 is equal to only two. 100 16 will be calculated as

100 16 = 10 16 * 10 16 = 16 10 * 16 10 = 256 10 .

It is also necessary to distinguish between the concepts of “digit” and “number”. A number is indicated by one symbol, and a number may be represented by several. For example, the number 9 10 in the binary system will look like 1001 2, and the number 9 in the binary system does not exist as such.

Translation algorithm

To convert a number to the decimal system, you need to learn how to use a simple algorithm.

  1. Determine the base of the number system. It is indicated by a subscript after the number, for example, in the number 2F7BE 16 the base is 16.
  2. Multiply each digit of the number by the base to a power equal to the number of the digit from right to left, starting from zero. In the number 2F7BE, 16 E (equal to 14) is multiplied by 16 to the zero power, B (digit 11) by 16 to the first power, and so on: 2F7BE 16 = 2*16 4 +15*16 3 + 7*16 2 + 11 *16 1 + 14*16 0 .
  3. Add up the results.

2*16 4 +15*16 3 + 7*16 2 + 11*16 1 + 14*16 0 = 194494 10 .

Let's look at examples of how the most popular are hexadecimal, octal and binary system convert to decimal.

  • 5736 8 = 5*8 3 + 7*8 2 + 3*8 1 + 6*8 0 = 3038 10
  • 1001011 2 = 1*2 6 + 0*2 5 + 0*2 4 + 1*2 3 + 0*2 2 + 1*2 1 + 1*2 0 = 75 10
  • 2F7BE 16 = 2*16 4 +15*16 3 + 7*16 2 + 11*16 1 + 14*16 0 = 194494 10

Of course, counting manually every time is inconvenient, irrational, and even reluctant. There are many calculators that can convert numbers from system to system. Eg, standard calculator Windows in Programmer mode (Alt+3 keys or View menu) can work with radix systems 2, 8, 10 and 16.







2024 gtavrl.ru.