Translation of numbers into binary, hexadecimal, decimal, octal number systems. Converting numbers to different number systems with a solution Algorithm for converting numbers from one number system to another

18.02.2022

Basic concepts of number systems

The 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 the system is called the base of the number system. The base of the system is written to the right 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 notation of the number;

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

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

Any integer in the positional system can be written as a polynomial:

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 is written in polynomial form as follows:

Types of number systems

The Roman numeral 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 numeral system, the value of a number is the algebraic sum of the digits included in it. In this case, the digits in the number entry follow, 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 a digit with a larger value is followed by a digit with a smaller value, 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 shown in the table.

Table 2. Writing numbers in the Roman numeral system

III

VII

VIII

XIII

XVIII

XIX

XXII

XXXIV

XXXIX

XXIX

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 writing numbers and, accordingly, arithmetic operations with multi-digit numbers. Due to inconvenience and great complexity, the Roman numeral system is currently used where it is really convenient: in literature (chapter numbering), in paperwork (a series of passports, securities, etc.), for decorative purposes on the 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, let alone arise. The reason why the decimal number system has become generally accepted is not at all mathematical. People are used to counting in decimal notation because they have 10 fingers on their hands.

The ancient image of decimal digits (Fig. 1) is not accidental: each digit denotes a number by the number of angles in it. For example, 0 - no corners, 1 - one corner, 2 - two corners, etc. The spelling of decimal digits 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 AD. Indian numbering used nine numeric characters and a zero to indicate an empty position. In the early Indian manuscripts that have come down to us, the numbers were written in reverse order - the most significant figure was placed on the right. But it soon became the rule to place such a figure on the left side. Particular importance was attached to the null symbol, which was introduced for the positional notation. Indian numbering, including zero, has come down to our time. 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). The Europeans borrowed the Indian number system from the Arabs, calling it Arabic. This historically incorrect name is retained 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 the number and a comma or period to separate the integer and fractional 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 a common misconception, the binary number system was invented not by computer design engineers, but by mathematicians and philosophers long before the advent of computers, back in the seventeenth and nineteenth 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 the article of the German mathematician Gottfried Wilhelm Leibniz, published in 1703. It explained the binary operations of addition, subtraction, multiplication and division. Leibniz did not recommend using 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 electronic elements - triggers that make up computer microcircuits, can only be in two working states.

With the help of a binary coding system, any data and knowledge can be recorded. This is easy to understand if you remember the principle of encoding and transmitting information using Morse code. A telegraph operator, using only two characters 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 down 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 translate it back, but all these translations are time consuming. Therefore, number systems are used that are related to binary - 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 decimal 10, hexadecimal B to decimal 11, and so on. 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 an important part of machine arithmetic. Consider the basic rules of translation.

1. To convert a binary number into a decimal one, it is necessary to write it as a polynomial consisting of the products of the digits of the number and the corresponding power of the number 2, and calculate according to the rules of decimal arithmetic:

When translating, it is convenient to use the table of powers of two:

Table 4. Powers of 2

n (degree)

1024

Example. Convert the number to decimal number system.

2. To translate an octal number into a decimal one, it is necessary to write it as a polynomial consisting of the products of the digits of the number and the corresponding power of the number 8, and calculate according to the rules of decimal arithmetic:

When translating, it is convenient to use the table of powers of eight:

Table 5. Powers of 8

n (degree)

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). 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 Entry" button.

original number recorded 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 record of a number 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 an entry

Translations completed: 3722471

It may also be of interest:

  • 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, and there is also the Roman one - it is just 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 the example of some number.

Example 1. Let's take the number 5921 in the decimal number system. We 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 the given number are taken as degrees.

Example 2. Consider the real decimal number 1234.567. We number it starting from the zero position of the number from the decimal point to the left and to the right:

The number 1234.567 can be written as follows: 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 easiest way to translate a number from one number system to another is to convert the number first to the decimal number system, and then, the result obtained to the required number system.

Converting numbers from any number system to decimal number system

To convert a number from any number system to decimal, it is enough to number its digits, starting from 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 number 1001101.1101 2 to 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 number E8F.2D 16 to 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 a decimal number system to another number system

To convert numbers from a decimal number system to another number system, the integer and fractional parts of the number must be translated separately.

Converting the integer part of a number from a decimal number system to another number system

The integer part is translated from the decimal number system to another number system by successively dividing the integer part of the number by the base of the number system until an integer remainder is obtained, less than the base of the number system. The result of the transfer will be a record from the remains, starting with the last one.

3. Convert number 273 10 to 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 remnants 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. So the translation is correct.
Answer: 273 10 = 421 8

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

Converting the fractional part of a number from a decimal number system to another number system

Recall that a proper decimal fraction is real number with zero integer part. To translate such a number into a number system with base N, you need to consistently 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 number 0.125 10 to binary number system.
Solution: 0.125 2 = 0.25 (0 is the integer part, which will be 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 , the translation is complete).
Answer: 0.125 10 = 0.001 2

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

Notation:

  • gives a representation of a set of numbers (integer and/or real);
  • 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 single position in the display of a number is called discharge, so the position number is rank number.

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

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

on the 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.

Correspondence table of numbers in various number systems.

Service assignment. The service is designed to translate numbers from one number system to another online. To do this, select the base of the system from which you want to translate the number. You can enter both integers and numbers with a comma.

You can enter either whole numbers, such as 34 , or fractional numbers, such as 637.333 . For fractional numbers, the accuracy of the translation after the decimal point is indicated.

The following are also used with this calculator:

Ways to represent numbers

Binary (binary) numbers - each digit means the value of one bit (0 or 1), the most significant bit is always written on the left, the letter “b” is placed after the number. For ease of perception, notebooks can be separated by spaces. For example, 1010 0101b.
Hexadecimal (hexadecimal) numbers - each tetrad is represented by one character 0...9, A, B, ..., F. Such a representation can be denoted in different ways, here only the character "h" is used after the last hexadecimal digit. For example, A5h. In program texts, the same number can be denoted both as 0xA5 and 0A5h, depending on the syntax of the programming language. A non-significant zero (0) is added to the left of the most significant hexadecimal digit represented by a letter to distinguish between numbers and symbolic names.
Decimals (decimal) numbers - each byte (word, double word) is represented by an ordinary number, and the sign of the decimal representation (letter "d") is usually omitted. The byte from the previous examples has a decimal value of 165. Unlike binary and hexadecimal notation, decimal is difficult to mentally determine the value of each bit, which sometimes has to be done.
Octal (octal) numbers - each triple of bits (separation starts from the least significant) is written as a number 0-7, at the end the sign "o" is put. The same number would be written as 245o. The octal system is inconvenient in that the byte cannot be divided equally.

Algorithm for converting numbers from one number system to another

The conversion of integer decimal numbers to any other number system is carried out by dividing the number by the base of the new number system until the remainder leaves a number less than the base of the new number system. The new number is written as the remainder of the division, starting with the last one.
The conversion of the correct decimal fraction to another PSS is carried out by multiplying only the fractional part of the number by the base of the new number system until all zeros remain in the fractional part or until the specified translation accuracy is reached. As a result of each multiplication operation, one digit of the new number is formed, starting from the highest.
The translation of an improper fraction is carried out according to the 1st and 2nd rules. The integer and fractional parts are written together, separated by a comma.

Example #1.



Translation from 2 to 8 to 16 number system.
These systems are multiples of two, therefore, the translation is carried out using the correspondence table (see below).

To convert a number from a binary number system to an octal (hexadecimal) number, it is necessary to divide the binary number into groups of three (four for hexadecimal) digits from a comma to the right and left, complementing the extreme groups with zeros if necessary. Each group is replaced by the corresponding octal or hexadecimal digit.

Example #2. 1010111010.1011 = 1.010.111.010.101.1 = 1272.51 8
here 001=1; 010=2; 111=7; 010=2; 101=5; 001=1

When converting to hexadecimal, you must divide the number into parts, four digits each, following the same rules.
Example #3. 1010111010.1011 = 10.1011.1010.1011 = 2B12.13 HEX
here 0010=2; 1011=B; 1010=12; 1011=13

The conversion of numbers from 2, 8 and 16 to the decimal system is carried out by breaking the number into separate ones and multiplying it by the base of the system (from which the number is translated) raised to the power corresponding to its ordinal number in the translated number. In this case, the numbers are numbered to the left of the decimal point (the first number has the number 0) with increasing, and to the right with decreasing (ie, with a negative sign). The results obtained are added up.

Example #4.
Example of converting from binary to decimal number system.

1010010.101 2 = 1 2 6 +0 2 5 +1 2 4 +0 2 3 +0 2 2 +1 2 1 +0 2 0 + 1 2 -1 +0 2 - 2 +1 2 -3 =
= 64+0+16+0+0+2+0+0.5+0+0.125 = 82.625 10 Example of conversion from octal to decimal number system. 108.5 8 = 1* 8 2 +0 8 1 +8 8 0 + 5 8 -1 = 64+0+8+0.625 = 72.625 10 An example of converting from hexadecimal to decimal number system. 108.5 16 = 1 16 2 +0 16 1 +8 16 0 + 5 16 -1 = 256+0+8+0.3125 = 264.3125 10

Once again, we repeat the algorithm for translating numbers from one number system to another PSS

  1. From the decimal number system:
    • divide the number by the base of the number system being translated;
    • find the remainder after dividing the integer part of the number;
    • write down all remainders from division in reverse order;
  2. From the binary system
    • To convert to the decimal number system, you need to find the sum of the products of base 2 by the corresponding degree of discharge;
    • To convert a number to octal, you need to break the number into triads.
      For example, 1000110 = 1000 110 = 106 8
    • To convert a number from binary to hexadecimal, you need to divide the number into groups of 4 digits.
      For example, 1000110 = 100 0110 = 46 16
The system is called positional., for which the significance or weight of a digit depends on its location in the number. The relationship between systems is expressed in a table.
Table of correspondence of number systems:
Binary SSHexadecimal SS
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F

Table for converting to octal number system

Example #2. Convert the number 100.12 from decimal to octal and vice versa. Explain the reasons for the discrepancies.
Solution.
Stage 1. .

The remainder of the division is written in reverse order. We get the number in the 8th number system: 144
100 = 144 8

To translate the fractional part of a number, we successively multiply the fractional part by base 8. As a result, each time we write down the integer part of the product.
0.12*8 = 0.96 (whole part 0 )
0.96*8 = 7.68 (whole part 7 )
0.68*8 = 5.44 (whole part 5 )
0.44*8 = 3.52 (whole part 3 )
We get the number in the 8th number system: 0753.
0.12 = 0.753 8

100,12 10 = 144,0753 8

Stage 2. Converting a number from decimal to octal.
Reverse conversion from octal to decimal.

To translate the integer part, it is necessary to multiply the digit of the number by the corresponding degree of digit.
144 = 8 2 *1 + 8 1 *4 + 8 0 *4 = 64 + 32 + 4 = 100

To translate the fractional part, it is necessary to divide the digit of the number by the corresponding degree of digit
0753 = 8 -1 *0 + 8 -2 *7 + 8 -3 *5 + 8 -4 *3 = 0.119873046875 = 0.1199

144,0753 8 = 100,96 10
The difference of 0.0001 (100.12 - 100.1199) is due to a rounding error when converting to octal. This error can be reduced if we take a larger number of digits (for example, not 4, but 8).

Number system (English numeral system or system of numeration) - a symbolic method of writing numbers, representing numbers using written characters

What is the base and base of the number system?

Definition: The base of the number system is the number of different characters or symbols that
are used to represent digits in this system.
Any natural number is taken as the base - 2, 3, 4, 16, etc. That is, there is an infinite
many positional systems. For example, for the decimal system, the base is 10.

Determining the base is very easy, you just need to recalculate the number of significant digits in the system. Simply put, this is the number from which the second digit of the number begins. For example, we use the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. There are exactly 10 of them, so the base of our number system is also 10, and the number system is called “decimal”. The above example uses the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (auxiliary 10, 100, 1000, 10000, etc. do not count). There are also 10 main digits, and the number system is decimal.

System base is the sequence of digits used to write . In no system is there a digit equal to the base of the system.

As you can guess, how many numbers there are, there can be as many bases of number systems. But only the most convenient bases of number systems are used. Why do you think the base of the most common human number system is 10? Yes, precisely because we have 10 fingers on our hands. “But there are only five fingers on one hand,” some will say, and they will be right. The history of mankind knows examples of five-fold number systems. “And with legs - twenty fingers” - others will say, and they will also be absolutely right. That's what the Mayans thought. You can even see it in their numbers.

Decimal number system

We are all accustomed to using numbers and numbers familiar to us from childhood when counting. One, two, three, four, etc. In our everyday number system, there are only ten digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), from which we make up any numbers. Having reached ten, we add one to the digit to the left and again start counting from zero in the rightmost digit. This number system is called decimal.

It is not difficult to guess that our ancestors chose it because the number of fingers on both hands is ten. But what other number systems are there? Was the decimal system always used, or were there others?

The history of the emergence of number systems

Before the invention of zero, special signs were used to write numbers. Each nation had its own. In ancient Rome, for example, a non-positional number system dominated.

A number system is called non-positional if the value of a digit does not depend on the place it occupies. The most advanced number systems were considered to be the number systems used in Russia and Ancient Greece.

In them, large numbers were denoted by letters, but with the addition of additional signs (1 - a, 100 - i, etc.). Another non-positional number system was the one used in ancient Babylon. In their system, the inhabitants of Babylon used a record of “two floors” and only three signs: One in the Babylonian number system for one, Ten in the Babylonian number system for ten, and Zero in the Babylonian number system for zero.

Positional number systems

Positional systems have become a step forward. Now the decimal has won everywhere, but there are other systems often used in applied sciences. An example of such a number system is the binary number system.
Binary number system

It is on it that computers and all the electronics in your home communicate. In this number system, only two digits are used: 0 and 1. You ask, why was it not possible to teach a computer to count to ten, like a person? The answer lies on the surface.

It is easy to teach a machine to distinguish between two characters: on means 1, off means 0; there is a current - 1, no current - 0. There were attempts to make machines that could distinguish a larger number of digits. But all of them turned out to be unreliable, computers always confused: either 1 came to them, or 2.

We are surrounded by many different number systems. Each of them is useful in its own area. And the answer to the question of which and when to use remains with us.



Similar articles