Hexadecimal system

format_list_bulleted Contenido keyboard_arrow_down
ImprimirCitar

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=0oct0000
1Hex=1dec=1oct0001
2Hex=2dec=2oct0010
3Hex=3dec=3oct0011
4Hex=4dec=4oct0100
5Hex=5dec=5oct0101
6Hex=6dec=6oct0110
7Hex=7dec=7oct0111
8Hex=8dec=10oct1000
9Hex=9dec=11oct1001
AHex=10dec=12oct1010
BHex=11dec=13oct1011
CHex=12dec=14oct1100
DHex=13dec=15oct1101
EHex=14dec=16oct1110
FHex=15dec=17oct1111

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.

FractionHexadecimalResults in hexadecimal
1/21/20.8
1/31/30,5 newspaper
1/41/40.4
1/5 1/5 0,3 newspaper
1/61/60.2A newspaper
1/71/70,249 newspaper
1/81/80.2
1/91/90,1C7 newspaper
1/101/A0.19 newspaper
1/111/B0,1745D newspaper
1/121/C0.15 newspaper
1/131/D0,13B newspaper
1/141/E0.1249 newspaper
1/151/F0,1 newspaper
1/161/100.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:

HexadecimalDecimal
A10
B11
C12
D13
E14
F15

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:

123456789ABCDEF10
1123456789ABCDEF10
22468ACE10121416181A1C1E20
3369CF1215181B1E2124272A2D30
448C1014181C2024282C3034383C40
55AF14191E23282D32373C41464B50
66C12181E242A30363C42484E545A60
77E151C232A31383F464E545D626970
88101820283038404850586068707880
99121B242D363F48515A636C757E8790
AA141E28323C46505A646E78828C96A0
BB16212C37424E58636E79848F9AA5B0
CC1824303C4854606C7884909CA8B4C0
DD1A2734414E5D6875828F9CA9B6C3D0
EE1C2A38465462707E8C9AA8B6C4D2E0
FF1E2D3C4B5A69788796A5B4C3D2E1F0
10102030405060708090A0B0C0D0E0F0100

Contenido relacionado

CASE Tool

These tools can help in all aspects of the software development life cycle in tasks such as the process of making a project design, cost calculation...

Smalltalk

Smalltalk is a reflexive, object-oriented, dynamically typed programming language. Due to its characteristics, Smalltalk can also be considered as an object...

Internet Message Control Protocol

The Internet control message protocol is part of the set of IP protocols. It is used to send error messages and operational information indicating, for...
Más resultados...
Tamaño del texto:
undoredo
format_boldformat_italicformat_underlinedstrikethrough_ssuperscriptsubscriptlink
save