From 16 to 10 number system calculator. Binary octal hexadecimal number system


Hexadecimal number system(also hexadecimal code) is a positional number system with integer base 16. Sometimes the term hex is also used in the literature (pronounced "hex", short for English hexadecimal). The numbers of this number system are commonly used Arabic numerals 0-9, as well as the first characters of the Latin alphabet A-F. The letters correspond to the following decimal values:

  • * A -10;
  • *B-11;
  • *C-12;
  • *D-13;
  • * E - 14;
  • * F - 15.

Thus, ten Arabic numerals, together with six Latin letters, make up the sixteen digits of the system.

By the way, on our website you can convert any text into decimal, hexadecimal, binary code using the Online Code Calculator.

Application. Hex code widely used in low-level programming, as well as in various computer reference documents. The popularity of the system is justified by the architectural solutions of modern computers: they have a byte (consisting of eight bits) as the minimum unit of information - and it is convenient to write the value of a byte using two hexadecimal digits. A byte value can range from #00 to #FF (0 to 255 in decimal notation) - in other words, using hex code, you can write any state of the byte, while there are no "extra" digits not used in the recording.

Encoded Unicode four hexadecimal digits are used to represent the character number. The RGB (Red, Green, Blue) color notation also often uses a hexadecimal code (for example, #FF0000 is a bright red notation).

A way to write a hexadecimal code.

Mathematical way of writing. In mathematical notation, the base of the system is written in decimal form in a subscript to the right of the number. The decimal notation for the number 3032 can be written as 3032 10 , in hexadecimal this number will be written as BD8 16 .

In the syntax of programming languages. The syntax of different programming languages ​​sets the format for writing a number using hex code:

* In the syntax of some varieties of assembly language, the Latin letter "h" is used, which is placed to the right of the number, for example: 20Dh. If the number starts with a Latin letter, then it is preceded by a zero, for example: 0A0Bh. This is done in order to distinguish values ​​from constants using hex code;

* Other varieties of assembler, as well as Pascal (and its varieties such as Delphi) and some Basic dialects, use the "$" prefix: $A15;

* In the HTML markup language, as well as in cascading CSS files, to specify a color in RGB format with a hexadecimal notation, the prefix "#" is used: #00DC00.

How to translate a hexadecimal code to another system?

Convert from hexadecimal to decimal. To perform a conversion operation from a hexadecimal system to a decimal one, it is required to represent the original number as the sum of the products of the digits in the digits of the hexadecimal number by the degree of the base.

Binary SS

hexadecimal ss

For example, you need to translate the hexadecimal number A14: it has three digits. Using the rule, we write it as a sum of powers with base 16:

A14 16 = 10.16 2 + 1.16 1 + 4.16 0 = 10.256 + 1.16 + 4.1 = 2560 + 16 + 4 = 2580 10

Converting numbers from binary to hexadecimal and vice versa.

For translation, a table of notebooks is used. To convert a number from binary to decimal, it is necessary to split it into separate tetrads from right to left, and then, using the table, replace each tetrad with the corresponding hexadecimal digit. In this case, if the number of digits is not a multiple of four, then it is necessary to add the corresponding number of zeros to the right of the number so that the total number of binary digits becomes a multiple of four.

Table of notebooks for translation.

To convert from hexadecimal to binary, you must perform the reverse operation: replace each digit with a tetrad from the table.

Binary SS

Octal SS

Example conversion from hexadecimal to binary: A5E 16 = 1010 0101 1110 = 101001011110 2

Example conversion from binary to hexadecimal: 111100111 2 = 0001 1110 0111 = 1E7 16

In this example, the number of digits in the original binary number was not four (9), so trailing zeros were added to bring the total number of digits to 12.

Automatic translation. Quick conversion from hexadecimal to one of the three popular systems (binary, octal and decimal), as well as reverse translation, can be performed using a standard calculator supplied with Windows. Open the calculator, select View -> Programmer from the menu. In this mode, you can set the number system currently used (see menu on the left: Hex, Dec, Oct, Bin). In this case, changing the current number system automatically translates.

Remark 1

If you want to convert a number from one number system to another, it is more convenient to first convert it to the decimal number system, and only then transfer 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, the conversion of numbers from one number system to another plays an important role. Below we present the basic rules for such transformations (translations).

    When converting a binary number to decimal, it is required to represent a binary number as a polynomial, each element of which is represented as a 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 above table $1$ of degrees 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 octal 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 $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 above table $2$ of degrees of 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 number $FFA2_(16)$ to decimal number system.

Solution. Using the above table of $3$ base powers of $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 a decimal number system to another

  • To convert a number from decimal to binary, it must be successively 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 remainder of the 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 decimal to octal, it must be successively divided by $8$ until there is a remainder less than or equal to $7$. Present a number in the octal number system as a sequence of digits of the last result of division and the remainder of the division in reverse order.

Example 5

Convert the number $571_(10)$ to octal number system.

Solution:

Figure 5

$571_{10} = 1073_8$

  • To convert a number from decimal to hexadecimal, it must be successively divided by $16$ until there is a remainder less than or equal to $15$. Express a number in hexadecimal as a sequence of digits of the last result of division 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 one, it is necessary to multiply the fractional part of the converted number by the base of the system into which it is to be converted. The fraction in the new system will be presented as whole parts of products, starting from the first.

    For example: $0.3125_((10))$ in octal would 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 a 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 to octal, it must be divided into triads (triples of digits), starting with the least significant digit, if necessary, adding zeros to the highest triad, then replacing each triad with the corresponding octal digit according to Table 4.

Figure 7. Table 4

Example 7

Convert the number $1001011_2$ to octal number system.

Solution. Using table 4, we translate the number from binary to octal:

$001 001 011_2 = 113_8$

  • To convert a number from binary to hexadecimal, it should be divided into tetrads (four digits), starting with the least significant digit, if necessary, supplementing the senior tetrad with zeros, then each tetrad should be replaced with the corresponding octal digit according to Table 4.

Any difficulties and misunderstandings with the conversion of numbers from binary to hexadecimal number system? Sign up for individual lessons in computer science and ICT. In our private lessons, my students and I analyze not only the theoretical part, but also solve a huge number of different thematic exercises.

You need to know what is a binary or binary number system

Before thinking about how to translate a number from 2 to 16, you need to have a good understanding of what numbers are in the binary number system. Let me remind you that the alphabet of the binary number system consists of two admissible elements - 0 and 1 . This means that absolutely any number written in binary will consist of a set of zeros and ones. Here are examples of numbers written in binary representation: 10010, 100, 111101010110, 1000001.

You need to know what the hexadecimal number system is

We figured out the binary system, remembered the basic points, now let's talk about the hexadecimal system. The alphabet of the hexadecimal number system consists of sixteen different characters: 10 Arabic numerals (from 0 to 9) and 6 first capital Latin letters (from "A" to "F"). This means that absolutely any number written in hexadecimal form will consist of the characters of the above alphabet. Here are examples of numbers written in hexadecimal notation:

810AFCDF198303 100FFF0

Let's talk about the algorithm for converting a number from 2 to hexadecimal number system

We will need to consider without fail the encoding table of Tetrads. Without the use of this table, it will be quite difficult to quickly translate numbers from 2 to 16 system.

The purpose of the Tetrad coding table is to uniquely match the characters of the binary number system and the hexadecimal number system.

The Tetrad table has the following structure:

Tetrad table

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

Let's say we need to convert the number 101011111001010 2 to hexadecimal system. First of all, it is necessary to divide the source binary code into groups of four digits, and, which is very important, the division must necessarily begin from right to left.

101 . 0111 . 1100 . 1010

After splitting, we got four groups: 101, 0111, 1100 and 1010. The leftmost segment, that is, segment 101, requires special attention. As you can see, its length is 3 digits, and it is necessary that its length be equal to four, therefore, we will supplement this segment leading leading zero:

101 -> 0 101.

Can you tell me, on what basis do we add some 0 to the left of the number? The thing is that adding insignificant zeros does not have any effect on the value of the original number. Therefore, we have every right to add not only one zero to the left of the binary number, but in principle any number of zeros and get a number of the desired length.

At the final stage of the transformation, it is necessary to translate each of the resulting binary groups into the corresponding value according to the Tetrad coding table.

0101 -> 5 0111 -> 7 1100 -> C 1010 -> A

101011111001010 2 = 57CA 16

And now I suggest that you familiarize yourself with the multimedia solution, which shows how it is converted from a binary state to a hexadecimal state:

Brief conclusions

In this short article, we have discussed the topic " Number systems: how to translate from 2 to 16". If you have any questions, misunderstandings, then call and sign up for my individual lessons in computer science and programming. I will offer you to solve more than a dozen of these exercises and you will not have a single question left. In general, number systems are an extremely important topic that forms the foundation used throughout the course.

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

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







2022 gtavrl.ru.