Hexadecimal system is a positional number system with base 16. Hexadecimal system is used to simplify the writing of binary numbers. Let's look at an example. Let there be a binary number. Its length is one byte:

10101111

We divide this number into two equal parts (half-bytes, nibbles):

1010 and 1111

Each nibble corresponds to a hexadecimal number:

A and F

ie our original binary number is equal to AF in hexadecimal form. That is the purpose of the hexadecimal number system: the number in the example is written in the binary system with 8 binary digits, and in the hexadecimal system with two hexadecimal digits.

How we get this result?

Hexadecimal system is used to simplify the writing of binary numbers. There are 16 hexadecimal digits:

0, 1, 2, 3, 4, 5, 6, 7,

8, 9, a, b, c, d, e, f

8, 9, a, b, c, d, e, f

they correspond to decimal numbers:

0, 1, 2, 3, 4, 5, 6, 7, 8,

9, 10, 11, 12, 13, 14, 15

9, 10, 11, 12, 13, 14, 15

Consider a nibble

1111

translate it into decimal form:

1 * 2^{3} + 1 * 2^{2} + 1 * 2^{1} + 1 * 2^{0} = 15

15 corresponds to F in hexadecimal notation.

Now another nibble:

1010

translate it into decimal form:

1 * 2^{3} + 0 * 2^{2} + 1 * 2^{1} + 0 * 2^{0} = 10

10 corresponds to A in hexadecimal notation. Thus, the binary number 10101111 corresponds to hex AF.

Another example. Suppose there is a binary number:

10

Obtain its hexadecimal notation. Hexadecimal digit corresponds to one nibble, but in this example there are only two bits. To get a nibble (4 bits), we add two leading zeros on the left:

0010

We have received four bits, and this is the nibble. Translate it into decimal form:

0 * 2^{3} + 0 * 2^{2} + 1 * 2^{1} + 0 * 2^{0} = 2

2 in decimal notation corresponds to 2 in hexadecimal notation. Thus, the binary number 10 corresponds to hexadecimal 2.

To distinguish hexadecimal numbers from other numbers, they add "H" to the hexadecimal number, for example:

2H