Hexadecimal system
The system hexadecimal (abbreviated) Hex.) is the positioning numbering system that is based on 16. Its current use is very linked to computer science and computer science where CPU operations usually use the byte or octeto as a basic memory unit, because a byte represents 28{displaystyle 2^{8}} possible values, and this can be represented as 28=24⋅ ⋅ 24=16⋅ ⋅ 16={displaystyle 2^{8}=2^{4}cdot 2^{4}=16cdot 16=}1⋅ ⋅ 162+0⋅ ⋅ 161+0⋅ ⋅ 160{displaystyle 1cdot 16^{2}+0cdot 16^{1}+0cdot 16^{0}}}, equivalent to base number 16 10016{displaystyle 100_{16}; two hexadecimal digits correspond exactly to a byte.
In principle, since the usual numeral system is decimal based and, therefore, only ten digits are available, the convention of using the first six letters of the Latin alphabet was adopted to replace the missing digits. The set of symbols is as follows:
S={0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F!{displaystyle S={0,1,2,3,4,5,6,7,8,9mathrm {A}mathrm {B}mathrm {C}mathrm {D}mathrm {E}mathrm {F},}}
Note that the letters correspond to the following decimal numerical values:
- A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
Sometimes lowercase letters are used instead of uppercase. As in any positional numbering system, the numerical value of each digit is altered depending on its position in the string of digits, being multiplied by a certain power of the base of the system, which in this case is 16. For example: 3E0A16 = 3×163 + E×162 + 0×161 + A×16 0 = 3×4096 + 14×256 + 0×16 + 10×1 = 15882.
The current hexadecimal system was first introduced to computing by IBM in 1963. An earlier representation, with 0-9 and u-z, was used in 1956 by the Bendix G-15 computer.
Conversion table between hexadecimal, decimal, octal and binary
0Hex | = | 0dec | = | 0oct | 0 | 0 | 0 | 0 | |||
1Hex | = | 1dec | = | 1oct | 0 | 0 | 0 | 1 | |||
2Hex | = | 2dec | = | 2oct | 0 | 0 | 1 | 0 | |||
3Hex | = | 3dec | = | 3oct | 0 | 0 | 1 | 1 | |||
4Hex | = | 4dec | = | 4oct | 0 | 1 | 0 | 0 | |||
5Hex | = | 5dec | = | 5oct | 0 | 1 | 0 | 1 | |||
6Hex | = | 6dec | = | 6oct | 0 | 1 | 1 | 0 | |||
7Hex | = | 7dec | = | 7oct | 0 | 1 | 1 | 1 | |||
8Hex | = | 8dec | = | 10oct | 1 | 0 | 0 | 0 | |||
9Hex | = | 9dec | = | 11oct | 1 | 0 | 0 | 1 | |||
AHex | = | 10dec | = | 12oct | 1 | 0 | 1 | 0 | |||
BHex | = | 11dec | = | 13oct | 1 | 0 | 1 | 1 | |||
CHex | = | 12dec | = | 14oct | 1 | 1 | 0 | 0 | |||
DHex | = | 13dec | = | 15oct | 1 | 1 | 0 | 1 | |||
EHex | = | 14dec | = | 16oct | 1 | 1 | 1 | 0 | |||
FHex | = | 15dec | = | 17oct | 1 | 1 | 1 | 1 | |||
Fractions
Since the only prime factor of 16 is 2, all fractions that do not have a power of 2 in the denominator will have periodic hexadecimal expansion.
Fraction | Hexadecimal | Results in hexadecimal |
---|---|---|
1/2 | 1/2 | 0.8 |
1/3 | 1/3 | 0,5 newspaper |
1/4 | 1/4 | 0.4 |
1/5 | 1/5 | 0,3 newspaper |
1/6 | 1/6 | 0.2A newspaper |
1/7 | 1/7 | 0,249 newspaper |
1/8 | 1/8 | 0.2 |
1/9 | 1/9 | 0,1C7 newspaper |
1/10 | 1/A | 0.19 newspaper |
1/11 | 1/B | 0,1745D newspaper |
1/12 | 1/C | 0.15 newspaper |
1/13 | 1/D | 0,13B newspaper |
1/14 | 1/E | 0.1249 newspaper |
1/15 | 1/F | 0,1 newspaper |
1/16 | 1/10 | 0.1 |
There is a system for converting fractional numbers to hexadecimal in a more mechanical way. It is about converting the integer part with the usual procedure and converting the decimal part by applying successive multiplications by 16 until the result becomes an integer.
For example: 0.06640625 in decimal base.
Multiplied by 16: 1.0625, the first decimal will be 1. We multiply the decimal part of the previous result by 16: 1. Therefore the next decimal will be 1.Result: 0.11 in hexadecimal base. Since the last result is an integer, we have finished the conversion.
There are times when we never get an integer, in which case we will have a periodic hexadecimal development.
Operations in hexadecimal system
In the hexadecimal system, as in the decimal, binary and octal systems, you can perform various mathematical operations. Among them is the subtraction between two numbers in hexadecimal system, which can be done with the 15's complement method or also using the 16's complement method. In addition to these, we must properly handle the addition in hexadecimal system, explained below:
Hexadecimal | Decimal |
---|---|
A | 10 |
B | 11 |
C | 12 |
D | 13 |
E | 14 |
F | 15 |
Sum
- 9 + 7 = 16 (16 - 16 = 0 we take 1 and it is = 10)
In this case, the answer obtained, 16, is not between 0 and 15, so we have to subtract 16. Therefore, the answer obtained will be 10 (hexadecimal system).
You have to be careful to use the letters correctly, since operating with letters and numbers at the same time can create confusion.
- A + 6 = 16 (16 - 16 = 0 and we take 1)
The same thing happens as in the previous example.
- A + A = 20 (20 - 16 = 4 and we take 1)
The answer is 20 and it is not between 0 and 15, so we have to subtract 16 from it. Therefore, the answer obtained will be 14 (hexadecimal system).
You have to be careful to use the letters correctly, since operating with letters and numbers at the same time can create confusion.
- F + E = 29 (29 - 16 = D and we'll take 1)
The answer is 29 and it is not between 0 and 15, so we have to subtract 16 from it. Therefore, the answer obtained will be 1D (hexadecimal system).
You have to be careful to use the letters correctly, since operating with letters and numbers at the same time can create confusion.
- Now we'll do a more complicated operation:
- A + 2 = 12 (12 corresponds to C)
Note that you can check the results using a scientific calculator
Hex Subtraction
C15 Plugin
How can we subtract two hexadecimal numbers using the 15's complement. To do this we will have to add the fifteen's complement of the subtrahend to the minuend, and finally add the overflow bit.
To understand subtraction in 15's complement we will analyze it with an example. This is the subtraction we have to solve:
A4FC9 - DE8 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— ?
First we need to make the minuend and subtrahend have the same number of numbers. To do this, we will add zeros to the subtrahend until they are enough.
A4FC9 - 00DE8 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— ?
Next, we'll create a new number with the same number of numbers as the new subtrahend. Since in the hexadecimal system the largest number we have is 15, which corresponds to the letter F, we will have to write the F as many times as there are numbers in the subtrahend.
FFFFF- 00DE8 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— FF217
Subtraction is done following the general rules of common subtraction. The difference obtained is called the 15's complement. Remember the value corresponding to each letter when trading.
Now we will have to add the minuend and the complement to 15 using the addition in hexadecimal system, mentioned above.
A4FC9 + FF217 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— 1A41E0
With the addition we obtain the result 1A41E0, but it is not the final answer. You will have noticed that this new number has more digits than the initial numbers that we had to subtract. We have to remove the number on the left (in this case, 1) and add it.
A41E0 + 1 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— A41E1
The answer is A41E1.
Note that you can check the results using a scientific calculator.
C16 Plugin
We can also subtract two hexadecimal numbers using the 16's complement, following a similar process as in the case of the 15's complement. To solve the subtraction, we will have to add the sixteen's complement of the subtrahend to the minuend.
To understand subtraction in 16's complement we will analyze it with the previous example. This is the subtraction we have to solve:
A4FC9 - DE8 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— FF218
First we need to make the minuend and subtrahend have the same number of numbers, just like in the 15's complement process.
To do this, we will add zeros to the subtrahend until there are enough.
A4FC9 - 00DE8 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— FF218
Next, we'll create a new number with the same number of numbers as the new subtrahend.
As in the hexadecimal system the largest number we have is 15, which corresponds to the letter F, we will have to write the F as many times as there are numbers in the subtrahend.
FFFFF- 00DE8 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— FF217
Subtraction is done following the general rules of common subtraction.
Now we have to add 1 to the difference obtained. This step is very important, since it is the difference between doing the subtraction in the complement of 15 or 16, and it is easily forgotten. Also, remember that you are adding in hexadecimal system, following the same process explained above.
FF217 + 1 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— FF218
We will call the difference obtained and add one to it the complement of 16.
Now we will have to add the minuend and the complement to 16
A4FC9 + FF218 ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————— 1A41E1.
With the addition we obtain the result 1A41E1.
You will have noticed that this new number has more figures than the initial numbers that we had to subtract, which is impossible in a subtraction (that the difference is greater than the minuend and the subtrahend). For this reason, and being in the complement of 16, we will have to despise (eliminate) the number on the left. In this case it is 1.
The answer, therefore, is A41E1.
In both cases the answer obtained should be the same, since we have solved the same subtraction in hexadecimal system. Therefore, we will be able to verify that we have operated correctly by comparing the answers obtained in 15's complement and in 16's complement for the same subtraction.
Also, note that you can check the results using a scientific calculator.
Hexadecimal multiplication
The algorithm for hexadecimal multiplication of two multi-digit quantities is the same as in the decimal system. However, the multiplication table to be used must include all multiplications between two numbers less than the base:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | 10 | |
1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | 10 |
2 | 2 | 4 | 6 | 8 | A | C | E | 10 | 12 | 14 | 16 | 18 | 1A | 1C | 1E | 20 |
3 | 3 | 6 | 9 | C | F | 12 | 15 | 18 | 1B | 1E | 21 | 24 | 27 | 2A | 2D | 30 |
4 | 4 | 8 | C | 10 | 14 | 18 | 1C | 20 | 24 | 28 | 2C | 30 | 34 | 38 | 3C | 40 |
5 | 5 | A | F | 14 | 19 | 1E | 23 | 28 | 2D | 32 | 37 | 3C | 41 | 46 | 4B | 50 |
6 | 6 | C | 12 | 18 | 1E | 24 | 2A | 30 | 36 | 3C | 42 | 48 | 4E | 54 | 5A | 60 |
7 | 7 | E | 15 | 1C | 23 | 2A | 31 | 38 | 3F | 46 | 4E | 54 | 5D | 62 | 69 | 70 |
8 | 8 | 10 | 18 | 20 | 28 | 30 | 38 | 40 | 48 | 50 | 58 | 60 | 68 | 70 | 78 | 80 |
9 | 9 | 12 | 1B | 24 | 2D | 36 | 3F | 48 | 51 | 5A | 63 | 6C | 75 | 7E | 87 | 90 |
A | A | 14 | 1E | 28 | 32 | 3C | 46 | 50 | 5A | 64 | 6E | 78 | 82 | 8C | 96 | A0 |
B | B | 16 | 21 | 2C | 37 | 42 | 4E | 58 | 63 | 6E | 79 | 84 | 8F | 9A | A5 | B0 |
C | C | 18 | 24 | 30 | 3C | 48 | 54 | 60 | 6C | 78 | 84 | 90 | 9C | A8 | B4 | C0 |
D | D | 1A | 27 | 34 | 41 | 4E | 5D | 68 | 75 | 82 | 8F | 9C | A9 | B6 | C3 | D0 |
E | E | 1C | 2A | 38 | 46 | 54 | 62 | 70 | 7E | 8C | 9A | A8 | B6 | C4 | D2 | E0 |
F | F | 1E | 2D | 3C | 4B | 5A | 69 | 78 | 87 | 96 | A5 | B4 | C3 | D2 | E1 | F0 |
10 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | A0 | B0 | C0 | D0 | E0 | F0 | 100 |
Contenido relacionado
CASE Tool
Smalltalk
Internet Message Control Protocol