Quaternary number system calculator. How to convert from binary to decimal

In this article I will tell you the basics of computer technology - this is a binary system. This is the lowest level, these are the numbers by which the computer works. And you will learn how to transfer from one system

Table 1 - Representation of numbers in various systems
calculus (beginning)

Number systems

Decimal

Binary

Octal

Hexadecimal

BCD

To convert from decimal to binary, you have two options.

1) For example, the number 37 needs to be translated from decimal system into binary, then you need to divide it by two and then check the remainder of the division. If the remainder is odd, then we write one at the bottom and the next division cycle goes through an even number; if the remainder of the division is even, then we write zero. At the end you must get 1. And now we convert the resulting result into binary, and the number goes from right to left.

Step by step: 37 is an odd number, which means 1 , then 36/2 = 18. The number is even, which means 0. 18/2 = 9 is an odd number, which means 1 , then 8/2 = 4. The number is even, read 0. 4/2 = 2, an even number means 0, 2/2 = 1.

So we got the number. Don't forget to count from right to left: 100101 - now we have a number in the binary system. In general, this is written as a division in a column, as you see in the figure below:

2) But there is a second way. I like him better. Transfer from one system to another is as follows:

where ai - i-th digit numbers;
k - the number of digits in the fractional part of the number;
m - the number of digits in the integer part of the number;
N is the base of the number system.

The base of the number system N shows how many times the “weight” of the i-th digit is greater than the “weight” (i-1) of the digit. The integer part of a number is separated from the fractional part by a dot (comma).

The integer part of the number AN1, with the base N1, is converted to the number system with the base N2 by sequentially dividing the integer part of the number AN1 by the base N2 written as a number with the base N1, until a remainder is obtained. The resulting part is again divided by the base N2, and this process must repeat until the particle becomes smaller than the divisor. The resulting division residues and last part are written in the reverse order obtained by division. The generated number will be an integer with base N2.

The fractional part of the number AN1, with base N1, is converted into a number system with base N2 by sequentially multiplying the fractional part of the number AN1 by base N2, written as a number with base N1. With every multiplication whole part the product is taken as the next digit of the corresponding digit, and fractional part the remaining one is taken as the new multiplication. The number of multiplications determines the digit capacity of the resulting result, representing the fractional part of the number AN1 in the N2 number system. The fractional part of a number is often represented inaccurately when translated.

Let's do this with an example:

Convert from decimal to binary

37 in decimal must be converted to binary. Let's work with degrees:

2 0 = 1
2 1 = 2
2 2 = 4
2 3 = 8
2 4 = 16
2 5 = 32
2 6 = 64
2 7 = 128
2 8 = 256
2 9 = 512
2 10 = 1024 and so on... ad infinitum

This means: 37 - 32 = 5. 5 - 4 = 1. The answer is as follows in binary: 100101.

Let's convert the number 658 from decimal to binary:

658-512=146
146-128=18
18-16=2. In the binary system the number will look like: 1010010010.

Converting from decimal to octal

If you need to convert from decimal to octal, you must first convert to binary, and then convert from binary to octal. That is, it’s easier this way, although you can translate it right away. Using an algorithm similar to the one for converting to binary, see above.

Convert from decimal to hexadecimal

If you need to convert from decimal to hexadecimal, you must first convert to binary and then convert from binary to hexadecimal. That is, it’s easier this way, although you can translate it right away. Using an algorithm similar to the one for converting to binary, see above.

Converting from binary to octal

To convert a number from binary to octal, you need to split the binary into three numbers.

For example, the resulting number 1010010010 is divided into three numbers, and the division goes from right to left: 1,010,010,010 = 1222. See the table at the very beginning.

Converting from binary to hexadecimal

To convert a number from binary to hexadecimal, you need to divide it into tetrads (four each)

10 1001 0010 = 292

Here are a few examples for you to look through:

Conversion is from binary to octal, then to hexadecimal, and then from binary to decimal

(2) = 11101110
(8) = 11 101 110 = 276
(16) = 1110 1110 = EE
(10) = 1*128+ 1*64+ 1*32+ 0 +1*8 + 1*4 + 1*2+ 0= 238
3) (8) = 657

Conversion is carried out from hexadecimal to binary, then to octal, and then from binary to decimal

(16) = 6E8
(2) = 110 1110 1000
(8) = 11 011 101 000 = 2250
(10) = 1*1024+1*512+ 0 +1*128+ 1*64+ 1*32+ 8 = 1768

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: 1237182

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

Recall that a proper decimal fraction is 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 is zeroed 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

Share
Copyright 2024. shongames.ru. Android. Operating system. Multimedia. Social media. Tools. Codecs. Graphics. All rights reserved.

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 decimal, you need to represent binary number in the form of a polynomial, each element of which is represented as the product of a digit of a number and the corresponding power of the base number, in this case $2$, and then you need to calculate the polynomial according to 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 binary system numbering into 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.

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 ones 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 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. To avoid new conventions, the 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.

To make a number from hexadecimal systems, you need to multiply each of its digits by the corresponding power of sixteen and add the results. For example, the number #11A in decimal notation is 10*(16^0) + 1*(16^1) + 1*(16^2) = 10 + 16 + 256 = 282.

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

Octal, hexadecimal and decimal systems are also widely used among positional systems. And if for the first two the second method is more applicable, then for translation from both are applicable.

Consider a decimal number to binary system by sequential division by 2. To convert a decimal number 25 V

2.3. Converting numbers from one number system to another

2.3.1. Converting integers from one number system to another

It is possible to formulate an algorithm for converting integers from a radix system p into a system with a base q :

1. Express the base of the new number system with numbers from the original number system and carry out all subsequent actions in the original number system.

2. Consistently divide the given number and the resulting integer quotients by the base of the new number system until we obtain a quotient that is smaller than the divisor.

3. The resulting remainders, which are digits of the number in the new number system, are brought into accordance with the alphabet of the new number system.

4. Compose a number in the new number system, writing it starting from the last remainder.

Example 2.12. Translate decimal number 173 10 in octal number system:

We get: 173 10 =255 8

Example 2.13. Convert the decimal number 173 10 to hexadecimal number system:

We get: 173 10 =AD 16.

Example 2.14. Convert the decimal number 11 10 to the binary number system. It is more convenient to depict the sequence of actions discussed above (translation algorithm) as follows:

We get: 11 10 =1011 2.

Example 2.15. Sometimes it is more convenient to write down the translation algorithm in table form. Let's convert the decimal number 363 10 to a binary number.

Divider

We get: 363 10 =101101011 2

2.3.2. Converting fractional numbers from one number system to another

It is possible to formulate an algorithm for converting a proper fraction with a base p into a fraction with a base q:

1. Express the base of the new number system with numbers from the original number system and carry out all subsequent actions in the original number system.

2. Consistently multiply the given numbers and the resulting fractional parts of the products by the base of the new system until the fractional part of the product becomes equal to zero or the required accuracy of number representation is achieved.

3. The resulting integer parts of the products, which are digits of the number in the new number system, should be brought into conformity with the alphabet of the new number system.

4. Compose the fractional part of a number in the new number system, starting with the integer part of the first product.

Example 2.17. Convert the number 0.65625 10 to the octal number system.

We get: 0.65625 10 =0.52 8

Example 2.17. Convert the number 0.65625 10 to hexadecimal number system.

x 16

We get: 0.65625 10 =0.A8 1

Example 2.18. Convert the decimal fraction 0.5625 10 to the binary number system.

x 2

x 2

x 2

x 2

We get: 0.5625 10 =0.1001 2

Example 2.19. Convert the decimal fraction 0.7 10 to the binary number system.

Obviously, this process can continue indefinitely, giving more and more new signs in the image of the binary equivalent of the number 0.7 10. So, in four steps we get the number 0.1011 2, and in seven steps the number 0.1011001 2, which is a more accurate representation of the number 0.7 10 in the binary number system, etc. Such an endless process is terminated at some step, when it is believed that the required accuracy of number representation has been obtained.

2.3.3. Translation of arbitrary numbers

Translation of arbitrary numbers, i.e. numbers containing an integer and a fractional part are carried out in two stages. The integer part is translated separately, and the fractional part separately. In the final recording of the resulting number, the integer part is separated from the fractional part by a comma (dot).

Example 2.20. Convert the number 17.25 10 to the binary number system.

We get: 17.25 10 =1001.01 2

Example 2.21. Convert the number 124.25 10 to octal system.

We get: 124.25 10 =174.2 8

2.3.4. Converting numbers from base 2 to base 2 n and vice versa

Translation of integers. If the base of the q-ary number system is a power of 2, then the conversion of numbers from the q-ary number system to the 2-ary number system and back can be carried out using more simple rules. In order to write an integer binary number in the number system with base q=2 n, you need:

1. Divide the binary number from right to left into groups of n digits each.

2. If the last left group has less than n digits, then it must be supplemented on the left with zeros to the required number of digits.

Example 2.22. The number 101100001000110010 2 will be converted to the octal number system.

We divide the number from right to left into triads and under each of them write the corresponding octal digit:

We get the octal representation of the original number: 541062 8.

Example 2.23. The number 1000000000111110000111 2 will be converted to the hexadecimal number system.

We divide the number from right to left into tetrads and under each of them write the corresponding hexadecimal digit:

We get the hexadecimal representation of the original number: 200F87 16.

Translation fractional numbers. In order to write a fractional binary number in a number system with base q=2 n, you need:

1. Divide the binary number from left to right into groups of n digits each.

2. If the last right group has less than n digits, then it must be supplemented on the right with zeros to the required number of digits.

3. Consider each group as an n-bit binary number and write it with the corresponding digit in the number system with the base q=2 n.

Example 2.24. The number 0.10110001 2 will be converted to the octal number system.

We divide the number from left to right into triads and under each of them we write the corresponding octal digit:

We get the octal representation of the original number: 0.542 8 .

Example 2.25. The number 0.100000000011 2 will be converted to the hexadecimal number system. We divide the number from left to right into tetrads and under each of them write the corresponding hexadecimal digit:

We get the hexadecimal representation of the original number: 0.803 16

Translation of arbitrary numbers. In order to write an arbitrary binary number in the number system with the base q=2 n, you need:

1. Divide the integer part of a given binary number from right to left, and the fractional part from left to right into groups of n digits each.

2. If the last left and/or right groups have less than n digits, then they must be supplemented on the left and/or right with zeros to the required number of digits;

3. Consider each group as an n-bit binary number and write it with the corresponding digit in the number system with the base q = 2 n

Example 2.26. The number 111100101.0111 2 will be converted to the octal number system.

We divide the integer and fractional parts of the number into triads and under each of them write the corresponding octal digit:

We get the octal representation of the original number: 745.34 8 .

Example 2.27. Let's convert the number 11101001000,11010010 2 into hexadecimal number system.

We divide the integer and fractional parts of the number into notebooks and under each of them write the corresponding hexadecimal digit:

We get the hexadecimal representation of the original number: 748,D2 16.

Converting numbers from number systems with base q=2n to binary. In order to convert an arbitrary number written in the number system with the base q=2 n into the binary number system, you need to replace each digit of this number with its n-digit equivalent in the binary number system.

Example 2.28.Let's convert the hexadecimal number 4AC35 16 to the binary number system.

According to the algorithm:

We get: 1001010110000110101 2 .

Tasks for independent completion (Answers)

2.38. Fill out the table, in each row of which the same integer must be written in different number systems.

Binary

Octal

Decimal

Hexadecimal

2.39. Fill out the table, in each row of which the same fractional number must be written in different number systems.

Binary

Octal

Decimal

Hexadecimal

2.40. Fill out the table, in each row of which the same arbitrary number (the number can contain both an integer and a fractional part) must be written in different number systems.

Binary

Octal

Decimal

Hexadecimal

59.B