Converting numbers into different number systems with solutions. Converting numbers from one number system to another online Features of converting numbers into different number systems

To convert numbers from one number system to another, you must have basic information about number systems and the form of representation of numbers in them.

Quantity s The number of different digits used in a number system is called the base, or base of the number system. In general, a positive number X in a positional system with a base s can be represented as a polynomial:

Where s- base of the number system, - numbers allowed in a given number system. The sequence forms a whole part X, and the sequence is the fractional part X.

In computing, the most widely used are binary (BIN - binary) and binary coded number systems: octal (OCT - octal), hexadecimal (HEX - hexadecimal) and binary coded decimal (BCD - binary coded decimal).

In the future, to indicate the number system used, the number will be enclosed in parentheses, and the base of the system will be indicated in the index. Number X based on s will be indicated .

Binary number system

The base of the number system is the number 2 ( s= 2) and only two digits are used to write numbers: 0 and 1. To represent any digit of a binary number, it is enough to have a physical element with two clearly different stable states, one of which represents 1 and the other 0.

Before you start converting from any number system to binary, you need to carefully study an example of writing a number in the binary number system:

If you do not need to go deep into the theory, but just need to get the result, then use Online calculator Converting integers from the decimal number system to other systems .

Octal and hexadecimal number systems

These number systems are binary-coded, in which the base of the number system is an integer power of two: - for octal and - for hexadecimal.

In the octal number system( s= 8) 8 digits are used: 0, 1, 2, 3, 4, 5, 6, 7.

Before you start converting from any number system to octal, you need to carefully study an example of writing a number in the octal system:

In hexadecimal number system ( s= 16) 16 digits are used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

An example of writing a number in hexadecimal:

The widespread use of octal and hexadecimal number systems is due to two factors.

Firstly, these systems allow you to replace the notation of a binary number with a more compact representation (the notation of a number in octal and hexadecimal systems will be 3 and 4 times shorter than the binary notation of this number, respectively). Secondly, the mutual conversion of numbers between the binary system on the one hand and the octal and hexadecimal systems on the other is relatively simple. Indeed, since for an octal number each digit is represented by a group of three binary digits (triads), and for a hexadecimal number - by a group of four binary digits (tetrads), then to convert a binary number it is enough to combine its digits into groups of 3 or 4 digits, respectively, moving from the comma to the right and left. In this case, if necessary, zeros are added to the left of the integer part and/or to the right of the fractional part and each such group - triad or tetrad - is replaced with an equivalent octal or hexadecimal digit (see table).

If you do not need to go deep into the theory, but just need to get the result, then use Online calculator Converting integers from the decimal number system to other systems .

Correspondence between digits in different number systems
DEC BIN OCT HEX BCD
0 0000 0 0 0000
1 0001 1 1 0001
2 0010 2 2 0010
3 0011 3 3 0011
4 0100 4 4 0100
5 0101 5 5 0101
6 0110 6 6 0110
7 0111 7 7 0111
8 1000 10 8 1000
9 1001 11 9 1001
10 1010 12 A 0001 0000
11 1011 13 B 0001 0001
12 1100 14 C 0001 0010
13 1101 15 D 0001 0011
14 1110 16 E 0001 0100
15 1111 17 F 0001 0101

For reverse translation, each OCT or HEX digit is replaced, respectively, by a triad or tetrad of binary digits, with insignificant zeros on the left and right being discarded.

For the examples discussed earlier, this looks like this:

If you do not need to go deep into the theory, but just need to get the result, then use Online calculator Converting integers from the decimal number system to other systems .

Binary decimal number system

In the BCD system, the weight of each digit is equal to a power of 10, as in the decimal system, and each decimal digit is encoded with four binary digits. To write a decimal number in the BCD system, it is enough to replace each decimal digit with an equivalent four-digit binary combination:

Any decimal number can be represented in BCD notation, but remember that it is not the binary equivalent of the number. This can be seen from the following example:

Converting numbers from one number system to another

Let X- a number in a number system with a base s, which needs to be represented in a system with a base h. It is convenient to distinguish two cases.

In the first case and, therefore, when moving to the base h you can use the arithmetic of this system. The conversion method consists of representing the number as a polynomial in powers s, as well as in the calculation of this polynomial according to the rules of arithmetic of the radix number system h. For example, it is convenient to switch from the binary or octal number system to the decimal number system. The described technique is illustrated by the following examples:

.

.

In both cases, arithmetic operations are performed according to the rules of the base 10 number system.

In the second case () it is more convenient to use radix arithmetic s. It should be taken into account here that the translation of integers and proper fractions is carried out according to different rules. When translating mixed fractions, the integer and fractional parts are each translated according to their own rules, after which the resulting numbers are written separated by commas.

Integer conversion

The rules for converting integers become clear from the general formula for writing a number in an arbitrary positional system. Let the number in the original number system s looks like . You need to get a number written in a number system with a base h:

.

To find the values, divide this polynomial by h:

.

As you can see, the least significant digit, that is, is equal to the first remainder. The next significant digit is determined by dividing the quotient by h:

.

The rest are also calculated by dividing the quotients until it equals zero.

To convert an integer from the s-ary number system to the h-ary number system, it is necessary to sequentially divide this number and the resulting quotients by h (according to the rules of the number system with base h) until the quotient becomes equal to zero. The most significant digit in the notation of a number with base h is the last remainder, and the digits following it form the remainders from previous divisions, written in the reverse order of their receipt.

Let's look at ways to convert numbers from one number system to another.

a) Converting a binary number to decimal.

It is necessary to add twos in powers corresponding to the positions where ones stand in binary. For example:

Let's take the number 20. In the binary system it has the following form: 10100.

So (we count from left to right, counting from 4 to 0; a number to the zero power is always equal to one)

10100 = 1*2 4 + 0*2 3 + 1*2 2 + 0*2 1 + 0*2 0 = 20

16+0+4+0+0 = 20.

b) Converting a decimal number to binary.

You need to divide it by two, writing the remainder from right to left:

20/2 = 10, remainder 0

10/2=5, remainder 0

5/2=2, remainder 1

2/2=1, remainder 0

1/2=0, remainder 1

As a result we get: 10100 = 20

c) Converting a hexadecimal number to decimal.

In the hexadecimal system, the position number of a digit in a number corresponds to the power to which the number 16 must be raised:

8A = 8*16 + 10 (0A) = 138

Finally, we present the algorithm for converting to and from the binary system, proposed by L. Radyuk.

Let A(cd) be an integer decimal number. Let's write it as a sum of powers of base 2 with binary coefficients. In its expanded form there will be no negative powers of the base (numbers 2):

A(td) = a(n-1) * 2^(n-1) + a(n-2) * 2^(n-2) + … + a(1) * 2^1 + a(0) * 2^0.

At the first step, we divide the number A(tsd) by the base of the binary system, that is, by 2. The quotient of the division will be equal to:

a(n-1) * 2^(n-2) + a(n-2) * 2^(n-3) + … + a(1), and the remainder is a(0).

At the second step, we again divide the integer quotient by 2, the remainder of the division will now be equal to a(1).

If we continue this division process, then after the nth step we get the sequence of residues:

a(0), a(1),…, a(n-1).

It is easy to notice that their sequence coincides with the reverse sequence of digits of an integer binary number written in collapsed form:

A(2) = a(n-1)...a(1)a(0).

Thus, it is enough to write the remainders in reverse order to obtain the desired binary number.

Then the algorithm itself will be as follows:

1. Consistently divide the original integer decimal number and the resulting integer quotients by the base of the system (by 2) until you get a quotient that is less than the divisor, that is, less than 2.

2. Write down the resulting remainders in reverse order, and add the last quotient to the left.

To convert numbers from octal and hexadecimal number systems to binary, you need to convert the digits of the number into groups of binary digits. To convert from the octal system to binary, each digit of the number must be converted into a group of three binary digits, a triad, and when converting a hexadecimal number into a group of four digits, a tetrad.

CONCLUSION

Summing up the results of the work, we can draw the following conclusions.

The positional number system consists of using a limited number of digits, but the position of each digit in the number provides the significance (weight) of this digit. The position of a digit in a number is called digit in mathematical language.

The base of a positional number system is the number of different signs or symbols (digits) used to display numbers in a given system.

To make binary numbers, which are quite long, easier to perceive and display, they are compressed into octal and hexadecimal number systems.

In computer technology, all types of information are encoded only by numbers or, more precisely, numbers that are represented in the binary number system, a method of representing any numbers using two signs (digits) according to the positional principle.

1. Ordinal counting in various number systems.

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 the octal number 511 to the decimal number system.

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

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

To convert a binary number into a number with a power of two base, 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 of the new number system.

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, done in the opposite direction: we replace each digit with a group of digits in the binary system from the correspondence 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:



From 16 or 8 to 2

Translation octal And hexadecimal numbers to binary system very simple: just replace each digit with its binary equivalent triad(three digits) or notebook(four digits) (see table).
Binary (Radise 2) Octal (Base 8) Decimal (Base 10) Hexadecimal (Base 16)
triads tetrads
0 1 0 1 2 3 4 5 6 7 000 001 010 011 100 101 110 111 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 A B C D E F 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

For example:

a) Translate 305.4 8 "2" s.s.

b) Translate 7B2.E 16 "2" s.s.

16A 16 =1 0110 1010 2 345 8 =11 100 101 2

From 2 to 16 or 8

For example:

a) Translate 1101111001.1101 2 "8" s.s.

b) Translate 11111111011.100111 2 "16" s.s.

1000101010010101 2 =1000 1010 1001 0101=8A95 16 = 1 000 101 010 010 101=105225 8

From 16 to 8 and back

Conversion from octal to hexadecimal and back is carried out through the binary system using triads and tetrads.

For example:

Translate 175.24 8 "16" s.s.

Result: 175.24 8 = 7D.5 16.

From 10 to any s.s.

For example:

a) Translate 181 10 "8" s.s.

Result: 181 10 = 265 8

b) Translate 622 10 "16" s.s.

Result: 622 10 = 26E 16

Translation of proper fractions
To convert a regular decimal fraction to another system, this fraction must be sequentially multiplied by the base of the system into which it is converted. In this case, only fractional parts are multiplied. Fractions in the new system are written in the form of whole parts of products, starting from the first.

For example:

Convert 0.3125 10 "8" s.s.

Result: 0.3125 10 = 0.24 8

Comment. A final decimal fraction in another number system may correspond to an infinite (sometimes periodic) fraction. In this case, the number of characters in the representation of a fraction in the new system is taken depending on the required accuracy.

For example:

Convert 0.65 10 "2" s.s. Accuracy 6 digits.

Result: 0.65 10 0.10(1001) 2

To convert an improper decimal fraction to a number system with a non-decimal base It is necessary to translate the whole part and the fractional part separately.

For example:

Translate 23.125 10 "2" s.s.

Thus: 23 10 = 10111 2 ; 0.125 10 = 0.001 2.
Result: 23.125 10 = 10111.001 2.

It should be noted that integers remain integers, and proper fractions remain fractions in any number system.

From 2, 8 or 16 to 10

For example:

a)10101101.101 2 = 1 2 7 + 0 2 6 + 1 2 5 + 0 2 4 + 1 2 3 + 1 2 2 + 0 2 1 + 1 2 0 + 1 2 -1 + 0 2 -2 + 1 2 - 3 = 173.625 10

b) Translate 703.04 8 "10" s.s.

703.04 8 = 7 8 2 + 0 8 1 + 3 8 0 + 0 8 -1 + 4 8 -2 = 451.0625 10

c) Translate B2E.4 16 "10" s.s.

B2E.4 16 = 11 16 2 + 2 16 1 + 14 16 0 + 4 16 -1 = 2862.25 10

Scheme for converting numbers from one number system to another


Arithmetic operations in positional number systems

Let's look at the basic arithmetic operations: addition, subtraction, multiplication and division. The rules for performing these operations in the decimal system are well known - these are addition, subtraction, multiplication by a column and division by an angle. These rules apply to all other positional number systems. Only addition and multiplication tables must be used specific for each system.

Addition

When adding, the numbers are summed up by digits, and if there is an excess, it is transferred to the left

When adding binary numbers in each digit, the digits of the terms are added and transferred from the adjacent low-order digit, if any. It is necessary to take into account that 1+1 gives a zero in a given digit and a carry unit to the next one.

For example:

Perform addition of binary numbers:
a) X=1101, Y=101;

Result 1101+101=10010.

b) X=1101, Y=101, Z=111;

Result 1101+101+111=11001.

Addition table in the 8th number system

2+2=4 3+2=5 4+2=6 5+2=7 6+2=10 7+2=11
2+3=5 3+3=6 4+3=7 5+3=10 6+3=11 7+3=12
2+4=6 3+4=7 4+4=10 5+4=11 6+4=12 7+4=13
2+5=7 3+5=10 4+5=11 5+5=12 6+5=13 7+5=14
2+6=10 3+6=11 4+6=12 5+6=13 6+6=14 7+6=15
2+7=11 3+7=12 4+7=13 5+7=14 6+7=15 7+7=16

Addition table in the 16th number system

+ A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A B C D E F
A A B C D E F
B B C D E F 1A
C C D E F 1A 1B
D D E F 1A 1B 1C
E E F 1A 1B 1C 1D
F F 1A 1B 1C 1D 1E

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

You may also be interested:

  • Truth table calculator. SDNF. SKNF. Zhegalkin polynomial

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

The simplest way to convert a number from one number system to another is to first convert the number to the decimal number system, and then the resulting result to 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

Let's consider the translation of regular decimal fractions into various number systems.

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

mob_info