Binary number system translation of ordinary numbers. Converting numbers to different number systems with solution
Most short system Numbers are 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.
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 performing operations led to the need for a more detailed study of 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 in 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's 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 (remaining 0)
23:2=11 (rest 1)
11:2=5 (remaining 1)
5:2=2 (rest.1)
After the division process is completed, then we write one in the quotient and all 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:
- 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.
- 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.
Convert from decimal to octal.
Write a decimal number in hexadecimal
Conversion from decimal to hexadecimal SS is carried out similarly using a substitution system. But in addition to numbers, they also use letters of the latin alphabet A, B, C, D, E, F. Where A denotes the remainder 10, and F the remainder 15. The decimal number is 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.
Converting numbers from one number system to another is an important part of machine arithmetic. Let's consider the basic rules of translation.
1. For translation binary number in decimal it is necessary to write it in the form of a polynomial, consisting of the products of the digits of a number and the corresponding power of 2, and calculate it according to the rules of decimal arithmetic:
When translating, it is convenient to use the table of powers of two:
Table 4. Powers of number 2
n (degree) |
|||||||||||
Example.
2. For translation octal number in decimal it is necessary to write it in the form of a polynomial, consisting of the products of the digits of the number and the corresponding power of the number 8, and calculate it according to the rules of decimal arithmetic:
When translating, it is convenient to use the table of powers of eight:
Table 5. Powers of the number 8
n (degree) |
|||||||
Example. Convert number to decimal system Reckoning.
3. For translation hexadecimal number in decimal it is necessary to write it in the form of a polynomial, consisting of the products of the digits of the number and the corresponding power of the number 16, and calculate it according to the rules of decimal arithmetic:
When translating, it is convenient to use blitz of powers of number 16:
Table 6. Powers of the number 16
n (degree) |
|||||||
Example. Convert the number to the decimal number system.
4. To convert a decimal number to the binary system, it must be sequentially divided by 2 until a remainder less than or equal to 1 remains. A number in the binary system is written as a sequence of the last division result and the remainders from the division in reverse order.
Example. Convert the number to the binary number system.
5. To convert a decimal number to the octal system, it must be successively divided by 8 until there remains a remainder less than or equal to 7. The number in octal system is written as a sequence of digits of the last division result and the remainders of the division in reverse order.
Example. Convert the number to the octal number system.
6. To convert a decimal number to hexadecimal system it must be successively divided by 16 until there remains a remainder less than or equal to 15. A number in hexadecimal is written as a sequence of digits of the last division result and the remainders of the division in reverse order.
Example. Convert the number to hexadecimal number system.
Note 1
If you want to convert a number from one number system to another, then it is more convenient to first convert it to the decimal number system, and only then convert it from the decimal number system to any other number system.
Rules for converting numbers from any number system to decimal
IN 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$. A number in the binary system is represented as a sequence of the last result of division and the remainders from division in reverse order.
Example 4
Convert the number $22_(10)$ to the binary number system.
Solution:
Figure 4.
$22_{10} = 10110_2$
- To convert a number from the decimal number system to octal, it must be sequentially divided by $8$ until there is a remainder less than or equal to $7$. A number in the octal number system is represented as a sequence of digits of the last division result and the remainders from the division in reverse order.
Example 5
Convert the number $571_(10)$ to the octal number system.
Solution:
Figure 5.
$571_{10} = 1073_8$
- To convert a number from the decimal number system to the hexadecimal system, it must be successively divided by $16$ until there is a remainder less than or equal to $15$. A number in the hexadecimal system is represented as a sequence of digits of the last division result and the remainder of the division in reverse order.
Example 6
Convert the number $7467_(10)$ to hexadecimal number system.
Solution:
Figure 6.
$7467_(10) = 1D2B_(16)$
In order to convert a proper fraction from a decimal number system to a non-decimal number system, it is necessary to sequentially multiply the fractional part of the number being converted by the base of the system to which it needs to be converted. 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.
Using the familiar decimal system in computer documentation and programming is very inconvenient. Converting from binary to decimal systems and vice versa is a very labor-intensive process.
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. 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 of the octal number with a triple from 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 the 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
We divide decimal number by two until we 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 the decimal fraction 235.62 corresponds to the binary fraction 11101011.100111.
Video on the topic
Please note
The binary fractional part of a 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 the decimal system is 0.1 in the binary system.
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 technology, 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.
In everyday life, we are accustomed to using the decimal number system, which we have known since school. However, besides it, there are many other systems. How to write numbers not in decimal, but, for example, in ?
How to convert any number from the decimal system to binary
The need to convert a decimal number to binary looks daunting only at first glance. In fact, it is quite simple - you don’t even have to look for online services to complete the transaction.
- For example, let's take the number 156, written in the decimal form we are familiar with, and try to convert it into binary form.
- The algorithm will look like this - the initial number will need to be divided by two, then again by 2, and again by 2 until the answer remains one.
- When performing division, it is not the integers that matter for conversion to binary, but the remainders. If, when dividing, the answer turns out to be an even number, then the remainder is written as the number 0; if it is odd, then as the number 1.
- In practice, you can easily verify that the initial binary series of remainders for the number 156 will look like this - 00111001. In order to turn it into a full-fledged binary code, this series will need to be written in reverse order - that is, 10011100.
The binary number 10011100, obtained as a result of a simple operation, will be the binary expression of the number 156.
Another example, but in the picture
Converting binary number to decimal system
The reverse conversion - from binary to decimal - may seem a little more complicated. But if you use a simple doubling method, then you can handle this task in a couple of minutes. For example, let's take the same number, 156, but in binary form - 10011100.
- The doubling method is based on the fact that at each step of the calculation, the so-called previous total is taken and the next digit is added to it.
- Since the previous total does not yet exist in the first step, here we always take 0, double it and add the first digit of the expression to it. In our example it will be 0 * 2 + 1 = 1.
- At the second step, we already have the previous total - it is equal to 1. This number needs to be doubled, and then the next one in order should be added to it, that is - 1 * 2 + 0 = 2.
- In the third, fourth and subsequent steps, the previous totals are still taken and added to the subsequent number in the expression.
When in binary notation Only one last digit will remain, and there will be nothing more to add; the operation will be completed. With a simple check, you can make sure that the answer contains the desired decimal number 156.