Converting numbers to binary, hexadecimal, decimal, octal number systems. Number systems - let's go to a computer science lesson How to determine the base of a number system

Before we start solving problems, we need to understand a few simple points.

Consider the decimal number 875. The last digit of the number (5) is the remainder of dividing the number 875 by 10. The last two digits form the number 75 - this is the remainder of dividing the number 875 by 100. Similar statements are true for any number system:

The last digit of a number is the remainder when dividing this number by the base of the number system.

The last two digits of a number are the remainder when the number is divided by the squared base.

For example, . Divide 23 by the system base 3, we get 7 and 2 as a remainder (2 is the last digit of a number in the ternary system). Divide 23 by 9 (base squared), we get 18 and 5 as a remainder (5 = ).

Let's return again to the usual decimal system. Number = 100000. That is 10 to the k power is one and k zeros.

A similar statement is true for any number system:

The base of the number system to the power k in this number system is written as one and k zeros.

For example, .

1. Finding the base of the number system

Example 1.

In a number system with some base, the decimal number 27 is written as 30. Specify this base.

Solution:

Let us denote the desired base x. Then .I.e. x = 9.

Example 2.

In a number system with some base, the decimal number 13 is written as 111. Specify this base.

Solution:

Let us denote the desired base x. Then

We solve the quadratic equation, we get roots 3 and -4. Since the base of the number system cannot be negative, the answer is 3.

Answer: 3

Example 3

Separated by commas, in ascending order, indicate all bases of number systems in which the number 29 ends in 5.

Solution:

If in some system the number 29 ends in 5, then the number reduced by 5 (29-5 = 24) ends in 0. We have already said earlier that a number ends in 0 in the case when it is divisible by the base of the system without a remainder. Those. we need to find all such numbers that are divisors of the number 24. These numbers are: 2, 3, 4, 6, 8, 12, 24. Note that in the number systems with base 2, 3, 4 there is no number 5 (and in the formulation problem, the number 29 ends in 5), which means that systems with bases remain: 6, 8, 12,

Answer: 6, 8, 12, 24

Example 4

Separated by commas, in ascending order, indicate all bases of number systems in which the number 71 ends in 13.

Solution:

If in some system a number ends in 13, then the base of this system is not less than 4 (otherwise there is no number 3 there).

A number reduced by 3 (71-3=68) ends in 10. That is. 68 is completely divided by the desired base of the system, and the quotient of this when divided by the base of the system gives a remainder of 0.

Let's write down all the integer divisors of the number 68: 2, 4, 17, 34, 68.

2 is not suitable, because the base is not less than 4. Let's check the remaining divisors:

68:4 = 17; 17:4 = 4 (rest 1) – suitable

68:17 = 4; 4:17 = 0 (rest 4) – not suitable

68:34 = 2; 2:17 = 0 (ost 2) – not suitable

68:68 = 1; 1:68 = 0 (rest 1) – suitable

Answer: 4.68

2. Search for numbers by conditions

Example 5

Separated by commas, in ascending order, list all decimal numbers not exceeding 25, the notation of which in the base four number system ends in 11?

Solution:

First, let's find out what the number 25 looks like in the base 4 number system.

Those. we need to find all numbers, no more than , that end in 11. According to the rule of sequential counting in the base 4 system,
we get the numbers and . We convert them to the decimal number system:

Answer: 5, 21

3. Solving equations

Example 6

Solve the equation:

Write your answer in the ternary system (there is no need to write the base of the number system in your answer).

Solution:

Let's convert all numbers to the decimal number system:

The quadratic equation has roots -8 and 6 (since the base of the system cannot be negative). .

Answer: 20

4. Counting the number of ones (zeros) in the binary notation of the value of an expression

To solve this type of problem, we need to remember how columnar addition and subtraction works:

When adding, a bitwise summation of the digits written under each other occurs, starting with the least significant digits. If the resulting sum of two digits is greater than or equal to the base of the number system, the remainder of dividing this sum by the base of the number system is written under the summed digits, and the integer part of dividing this sum by the base of the system is added to the sum of the following digits.

When subtracting, the digits written below each other are bitwise subtracted, starting with the least significant digits. If the first digit is less than the second, we “borrow” one from the adjacent (larger) digit. The unit occupied in the current digit is equal to the base of the number system. In decimal it is 10, in binary it is 2, in ternary it is 3, etc.

Example 7

How many units are contained in the binary notation of the expression value: ?

Solution:

Let's imagine all the numbers in the expression as powers of two:

In binary notation, 2 to the power of n looks like 1 followed by n zeros. Then summing up and , we get a number containing 2 units:

Now let's subtract 10,000 from the resulting number. According to the rules of subtraction, we borrow from the next digit.

Now add 1 to the resulting number:

We see that the result has 2013+1+1=2015 units.

Conversion to decimal number system

Task 1. What number in the decimal system corresponds to the number 24 16?

Solution.

24 16 = 2 * 16 1 + 4 * 16 0 = 32 + 4 = 36

Answer. 24 16 = 36 10

Task 2. It is known that X = 12 4 + 4 5 + 101 2. What is the value of X in the decimal number system?

Solution.


12 4 = 1 * 41 + 2 * 40 = 4 + 2 = 6
4 5 = 4 * 5 0 = 4
101 2 = 1 * 2 2 + 0 * 2 1 + 1 * 2 0 = 4 + 0 + 1 = 5
Find the number: X = 6 + 4 + 5 = 15

Answer. X = 15 10

Task 3. Calculate the value of the sum 10 2 + 45 8 + 10 16 in decimal notation.

Solution.

Let's convert each term to the decimal number system:
10 2 = 1 * 2 1 + 0 * 2 0 = 2
45 8 = 4 * 8 1 + 5 * 8 0 = 37
10 16 = 1 * 16 1 + 0 * 16 0 = 16
The sum is: 2 + 37 + 16 = 55

Conversion to binary number system

Task 1. What is the value of 37 in binary number system?

Solution.

You can convert by dividing by 2 and combining the remainders in reverse order.

Another way is to decompose the number into the sum of powers of two, starting with the highest, the calculated result of which is less than the given number. When converting, missing powers of a number should be replaced with zeros:

37 10 = 32 + 4 + 1 = 2 5 + 2 2 + 2 0 = 1 * 2 5 + 0 * 2 4 + 0 * 2 3 + 1 * 2 2 + 0 * 2 1 + 1 * 2 0 = 100101

Answer. 37 10 = 100101 2 .

Task 2. How many significant zeros are there in binary notation of the decimal number 73?

Solution.

Let us decompose the number 73 into the sum of powers of two, starting with the highest and subsequently multiplying the missing powers by zeros, and the existing ones by one:

73 10 = 64 + 8 + 1 = 2 6 + 2 3 + 2 0 = 1 * 2 6 + 0 * 2 5 + 0 * 2 4 + 1 * 2 3 + 0 * 2 2 + 0 * 2 1 + 1 * 2 0 = 1001001

Answer. The binary representation of the decimal number 73 has four significant zeros.

Task 3. Calculate the sum of the numbers x and y for x = D2 16, y = 37 8. Present the result in the binary number system.

Solution.

Recall that each digit of a hexadecimal number is formed by four binary digits, each digit of an octal number by three:

D2 16 = 1101 0010
37 8 = 011 111

Let's add up the resulting numbers:

11010010 11111 -------- 11110001

Answer. The sum of the numbers D2 16 and y = 37 8, represented in the binary number system, is 11110001.

Task 4. Given: a= D7 16, b= 331 8 . Which number c, written in the binary number system, meets the condition a< c < b ?

  1. 11011001
  2. 11011100
  3. 11010111
  4. 11011000

Solution.

Let's convert the numbers to the binary number system:

D7 16 = 11010111
331 8 = 11011001

The first four digits of all numbers are the same (1101). Therefore, the comparison is simplified to comparing the lower four digits.

The first number from the list is equal to the number b, therefore, is not suitable.

The second number is greater than b. The third number is a.

Only the fourth number is suitable: 0111< 1000 < 1001.

Answer. The fourth option (11011000) meets the condition a< c < b .

Tasks to determine values ​​in various number systems and their bases

Task 1. To encode the characters @, $, &, %, two-digit sequential binary numbers are used. The first character corresponds to the number 00. Using these characters, the following sequence was encoded: $%&&@$. Decode this sequence and convert the result to hexadecimal number system.

Solution.

1. Let's compare binary numbers to the characters they encode:
00 - @, 01 - $, 10 - &, 11 - %

3. Convert the binary number to the hexadecimal number system:
0111 1010 0001 = 7A1

Answer. 7A1 16.

Task 2. The garden has 100 x fruit trees, of which 33 x are apple trees, 22 x are pears, 16 x are plums, 17 x are cherries. What is the base of the number system (x).

Solution.

1. Note that all terms are two-digit numbers. In any number system they can be represented as follows:
a * x 1 + b * x 0 = ax + b, where a and b are the digits of the corresponding digits of the number.
For three-digit number it will be like this:
a * x 2 + b * x 1 + c * x 0 = ax 2 + bx + c

2. The condition of the problem is:
33 x + 22 x + 16 x + 17 x = 100 x
Let's substitute the numbers into the formulas:
3x + 3 + 2x +2 + 1x + 6 + 1x + 7 = 1x 2 + 0x + 0
7x + 18 = x 2

3. Solve the quadratic equation:
-x2 + 7x + 18 = 0
D = 7 2 – 4 * (-1) * 18 = 49 + 72 = 121. The square root of D is 11.
Roots of a quadratic equation:
x = (-7 + 11) / (2 * (-1)) = -2 or x = (-7 - 11) / (2 * (-1)) = 9

4. Negative number cannot be the basis of a number system. Therefore x can only be equal to 9.

Answer. The required base of the number system is 9.

Task 3. In a number system with some base, the decimal number 12 is written as 110. Find this base.

Solution.

First, we will write the number 110 through the formula for writing numbers in positional number systems to find the value in the decimal number system, and then we will find the base by brute force.

110 = 1 * x 2 + 1 * x 1 + 0 * x 0 = x 2 + x

We need to get 12. Let's try 2: 2 2 + 2 = 6. Try 3: 3 2 + 3 = 12.

This means that the base of the number system is 3.

Answer. The required base of the number system is 3.

Task 4. In which number system would the decimal number 173 be represented as 445?

Solution.
Let us denote the unknown base as X. We write the following equation:
173 10 = 4*X 2 + 4*X 1 + 5*X 0
Taking into account the fact that any positive number to the zero power is equal to 1, we will rewrite the equation (we will not indicate the base 10).
173 = 4*X 2 + 4*X + 5
Of course, such a quadratic equation can be solved using a discriminant, but there is a simpler solution. Subtract 4 from the right and left sides. We get
169 = 4*X 2 + 4*X + 1 or 13 2 = (2*X+1) 2
From here we get 2*X +1 = 13 (we discard the negative root). Or X = 6.
Answer: 173 10 = 445 6

Problems on finding several bases of number systems

There is a group of problems in which you need to list (in ascending or descending order) all bases of number systems in which the representation of a given number ends with a given digit. This problem is solved quite simply. First you need to subtract the given digit from the original number. The resulting number will be the first base of the number system. And all other bases can only be divisors of this number. (This statement is proven based on the rule for converting numbers from one number system to another - see paragraph 4). Just remember that the base of the number system cannot be less than a given digit!

Example
Separated by commas, in ascending order, indicate all bases of number systems in which the number 24 ends in 3.

Solution
24 – 3 =21 is the first base (13 21 = 13*21 1 +3*21 0 = 24).
21 is divisible by 3 and 7. The number 3 is not suitable, because There is no digit 3 in the base 3 number system.
Answer: 7, 21

Basic concepts of number systems

A number system is a set of rules and techniques for writing numbers using a set of digital characters. The number of digits required to write a number in a system is called the base of the number system. The base of the system is written on the right side of the number in the subscript: ; ; etc.

There are two types of number systems:

positional, when the value of each digit of a number is determined by its position in the number record;

non-positional, when the value of a digit in a number does not depend on its place in the number’s notation.

An example of a non-positional number system is the Roman one: numbers IX, IV, XV, etc. An example of a positional number system is the decimal system used every day.

Any integer in the positional system can be written in polynomial form:

where S is the base of the number system;

Digits of a number written in a given number system;

n is the number of digits of the number.

Example. Number will be written in polynomial form as follows:

Types of number systems

The Roman number system is a non-positional system. It uses letters of the Latin alphabet to write numbers. In this case, the letter I always means one, the letter V means five, X means ten, L means fifty, C means one hundred, D means five hundred, M means a thousand, etc. For example, the number 264 is written as CCLXIV. When writing numbers in the Roman number system, the value of a number is the algebraic sum of the digits included in it. In this case, the digits in the number record are, as a rule, in descending order of their values, and it is not allowed to write more than three identical digits side by side. In the case when behind the number with great value followed by a figure with a smaller one, its contribution to the value of the number as a whole is negative. Typical examples illustrating the general rules for writing numbers in the Roman numeral system are given in the table.

Table 2. Writing numbers in the Roman numeral system

III

VII

VIII

XIII

XVIII

XIX

XXII

XXXIV

XXXIX

XCIX

200

438

649

999

1207

CDXXXVIII

DCXLIX

CMXCIX

MCCVII

2045

3555

3678

3900

3999

MMXLV

MMMDLV

MMMDCLXXVIII

MMMCM

MMMCMXCIX

The disadvantage of the Roman system is the lack of formal rules for recording numbers and, accordingly, arithmetic operations with multi-digit numbers. Due to its inconvenience and great complexity, the Roman number system is currently used where it is truly convenient: in literature (chapter numbering), in the design of documents (a series of passports, securities, etc.), for decorative purposes on a watch dial and in a number of other cases.

The decimal number system is currently the most well-known and used. The invention of the decimal number system is one of the main achievements of human thought. Without it, modern technology could hardly exist, much less arise. The reason why the decimal number system became generally accepted is not at all mathematical. People are used to counting in the decimal number system because they have 10 fingers on their hands.

The ancient image of decimal digits (Fig. 1) is not accidental: each digit represents a number by the number of angles in it. For example, 0 - no corners, 1 - one corner, 2 - two corners, etc. The writing of decimal numbers has undergone significant changes. The form we use was established in the 16th century.

The decimal system first appeared in India around the 6th century new era. Indian numbering used nine numeric characters and a zero to indicate an empty position. In early Indian manuscripts that have come down to us, numbers were written in reverse order - the most significant number was placed on the right. But it soon became a rule to place such a number on the left side. Special significance was given a zero symbol, which was introduced for the positional notation system. Indian numbering, including zero, has survived to this day. In Europe, Hindu methods of decimal arithmetic became widespread at the beginning of the 13th century. thanks to the work of the Italian mathematician Leonardo of Pisa (Fibonacci). Europeans borrowed Indian system notation among the Arabs, calling it Arabic. This historical misnomer continues to this day.

The decimal system uses ten digits—0, 1, 2, 3, 4, 5, 6, 7, 8, and 9—as well as the symbols “+” and “–” to indicate the sign of a number, and a comma or period to separate the integer and decimal parts. numbers.

Computers use a binary number system, its base is the number 2. To write numbers in this system, only two digits are used - 0 and 1. Contrary to popular misconception, the binary number system was not invented by computer design engineers, but by mathematicians and philosophers long before the emergence of computers, back in the 17th - 19th centuries. The first published discussion of the binary number system is by the Spanish priest Juan Caramuel Lobkowitz (1670). General attention to this system was attracted by an article by the German mathematician Gottfried Wilhelm Leibniz, published in 1703. It explained the binary operations of addition, subtraction, multiplication and division. Leibniz did not recommend the use of this system for practical calculations, but emphasized its importance for theoretical research. Over time, the binary number system becomes well known and develops.

The choice of a binary system for use in computer technology is explained by the fact that the electronic elements - triggers that make up computer chips - can only be in two operating states.

Using the binary coding system, you can capture any data and knowledge. This is easy to understand if we recall the principle of encoding and transmitting information using Morse code. A telegraph operator, using only two symbols of this alphabet - dots and dashes, can transmit almost any text.

The binary system is convenient for a computer, but inconvenient for a person: the numbers are long and difficult to write and remember. Of course, you can convert the number to the decimal system and write it in this form, and then, when you need to convert it back, but all these translations are labor-intensive. Therefore, number systems related to binary are used - octal and hexadecimal. To write numbers in these systems, 8 and 16 digits are required, respectively. In hexadecimal, the first 10 digits are common, and then capital Latin letters are used. Hexadecimal digit A corresponds to the decimal number 10, hexadecimal B to the decimal number 11, etc. The use of these systems is explained by the fact that the transition to writing a number in any of these systems from its binary notation is very simple. Below is a table of correspondence between numbers written in different systems.

Table 3. Correspondence of numbers written in different number systems

Decimal

Binary

Octal

Hexadecimal

001

010

011

100

101

110

111

1000

1001

1010

1011

1100

1101

D http://viagrasstore.net/generic-viagra-soft/

1110

1111

10000

Rules for converting numbers from one number system to another

Converting numbers from one number system to another is important part machine arithmetic. Let's consider the basic rules of translation.

1. To convert a binary number to a decimal one, 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 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)

1024

Example. Convert the number to the decimal number system.

2. To convert an octal number to a decimal one, 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)

Notation is a method of writing a number using a specified set of special characters (digits).

Notation:

  • gives a representation of a set of numbers (integers and/or reals);
  • gives each number a unique representation (or at least a standard representation);
  • displays the algebraic and arithmetic structure of a number.

Writing a number in some number system is called number code.

A separate position in a number display is called discharge, which means the position number is rank number.

The number of digits in a number is called bit depth and coincides with its length.

Number systems are divided into positional And non-positional. Positional number systems are divided

on homogeneous And mixed.

octal number system, hexadecimal number system and other number systems.

Translation of number systems. Numbers can be converted from one number system to another.

Table of correspondence of numbers in different number systems.

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

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

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 remainder will have next view: 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

Let us remind you that the correct decimal called real number with zero integer part. To convert such a number to a number system with base N, you need to sequentially multiply the number by N until the fractional part 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



Items