Hexadecimal system

from Wikipedia, the free encyclopedia
Hexadecimal digits,
binary and decimal:
Hex. Dual system Dec
0 0 0 0 0 00
1 0 0 0 1 01
2 0 0 1 0 02
3 0 0 1 1 03
4th 0 1 0 0 04
5 0 1 0 1 05
6th 0 1 1 0 06
7th 0 1 1 1 07
8th 1 0 0 0 08
9 1 0 0 1 09
A. 1 0 1 0 10
B. 1 0 1 1 11
C. 1 1 0 0 12
D. 1 1 0 1 13
E. 1 1 1 0 14th
F. 1 1 1 1 15th

In the hexadecimal system , numbers are represented in a place value system based on 16. "Hexadecimal" (from Greek hexa "six" and Latin decem "ten") is a Latin-Greek mixed word; Another correct but seldom used designation is hexadecimal (from the Latin sedecim "sixteen"). Another alternative name is hexadecadic (Greek). On the other hand, the expression hexa ges imal, which is synonymous with sexa ges imal and denotes the number system based on base 60, is incorrect .

In the data processing the hexadecimal system is used very often, because it is ultimately up to a more comfortable administration of the binary system is. The data words exist in the computer science mostly of octets that can be held as an eight-digit binary numbers represented as two-digit hexadecimal numbers. In contrast to the decimal system, the hexadecimal system with its base as a fourth power of two (16 = 2 4 ) is suitable for simpler notation of binary numbers, as a fixed number of characters is always required to reproduce the data word. Nibbles can be represented exactly with one hexadecimal digit and bytes with two hexadecimal digits.

In the 1960s and 1970s, the octal system was also often used in computer science with its base as a third power of two (8 = 2 3 ), since it uses the usual digits from 0 to 7. However, it is rarely used today, for example to represent characters in the C programming language. There are also other number systems with different base values.

We are used to calculating in the decimal system . This means that our Indo-Arabic number system uses ten symbols for the notation of the digits ( 0 to 9 ). The hexadecimal system, on the other hand, contains sixteen digits. Since the mid-1950s, the letters A to F or a to f have been used as numerals to represent the six additional digits . This goes back to the practice of the IBM computer scientists at the time .

Representation of hexadecimal numbers

In order to be able to differentiate between hexadecimal and decimal numbers, there are several notations. Usually hexadecimal numbers are given an index or prefix .

Common spellings are: 72 16 , 72 hex , 72h, 72H, 72 H , 0x72, $ 72, "72 and X'72 ', whereby the prefix 0x and the suffix h are particularly used in programming and technical informatics h to the hex number is also known as the Intel convention. The notation with the dollar prefix is ​​common in the assembly languages ​​of certain processor families , especially Motorola , for example the Motorola 68xx and 68xxx , but also the MOS 65xx ; the notation X '72' is common in the world of IBM mainframes , as in REXX .

Separation points for clarity can be set at all four places in hexadecimal numbers, thus separating groups of sixteen bits each . The meaning of the 1,0000 16 = 65,536 10 among the hexadecimal numbers corresponds to that of the 1,000 10 among the decimal numbers.

For comparison, a full sixty-four-bit bus with and without breakpoints: FFFF.FFFF.FFFF.FFFF and FFFFFFFFFFFFFFFF

Decimal numbers are indexed where they are not the normal case to be expected: 114 10

Counting in the hexadecimal system

It is counted as follows:

0 1 2 3 4th 5 6th 7th 8th 9 A. B. C. D. E. F.
10 11 12 13 14th 15th 16 17th 18th 19th 1A 1B 1C 1D 1E 1F
20th 21st 22nd 23 24 25th 26th 27 28 29 2A 2 B 2C 2D 2E 2F
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
100 101 102 103 104 105 106 107 108 109 10A 10B 10C 10D 10E 10F
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
FF0 FF1 FF2 FF3 FF4 FF5 FF6 FF7 FF8 FF9 FFA FFB FFC FFD FFE FFF
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 100A 100B 100C 100D 100E 100F
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
FFF0 FFF1 FFF2 FFF3 FFF4 FFF5 FFF6 FFF7 FFF8 FFF9 FFFA FFFB FFFC FFFD FFFE FFFF
10,000 10001 10002 10003 10004 10005 10006 10007 10008 10009 1000A 1000B 1000C 1000D 1000E 1000F
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...

Pronunciation of hexadecimal numbers

No separate names are used for the hexadecimal digits and numbers. Hexadecimal numbers are therefore usually read digit by digit.

Examples:

  • 10 read: "one-zero" (rarely: "ten"),
  • 1E say: "one-E",
  • F112 read: "F-one-one-two".

Hexadecimal multiplication table (multiplication table)

Example: 2 • 5 = A

Go vertically down from the column with the value 2 to the intersection of the line with the value 5. Result: A

* 1 2 3 4th 5 6th 7th 8th 9 A. B. C. D. E. F. 10
1 1 2 3 4th 5 6th 7th 8th 9 A. B. C. D. E. F. 10
2 2 4th 6th 8th A. C. E. 10 12 14th 16 18th 1A 1C 1E 20th
3 3 6th 9 C. F. 12 15th 18th 1B 1E 21st 24 27 2A 2D 30th
4th 4th 8th C. 10 14th 18th 1C 20th 24 28 2C 30th 34 38 3C 40
5 5 A. F. 14th 19th 1E 23 28 2D 32 37 3C 41 46 4B 50
6th 6th C. 12 18th 1E 24 2A 30th 36 3C 42 48 4E 54 5A 60
7th 7th E. 15th 1C 23 2A 31 38 3F 46 4D 54 5B 62 69 70
8th 8th 10 18th 20th 28 30th 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. 14th 1E 28 32 3C 46 50 5A 64 6E 78 82 8C 96 A0
B. B. 16 21st 2C 37 42 4D 58 63 6E 79 84 8F 9A A5 B0
C. C. 18th 24 30th 3C 48 54 60 6C 78 84 90 9C A8 B4 C0
D. D. 1A 27 34 41 4E 5B 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 20th 30th 40 50 60 70 80 90 A0 B0 C0 D0 E0 F0 100

Hexadecimal fractions

Since the hexadecimal system is a place value system , the places after the comma (which is also sometimes written as a comma, sometimes as a point) have the place value , with the decimal base being 16 and the position of the respective decimal place. The first decimal place (n = 1) has the value , the second decimal place (n = 2) has the value , the third decimal place (n = 3) has the value and so on.

Since the number 16 only has the single prime factor  2, all abbreviated fractions whose denominator is not a power of two have a periodic point representation in the hexadecimal system:

= 1 = 0, 3 16 = 0.1C7 16 = 0.13B 16
= 0.8 16 = 0.2 A 16 = 0.1 9 16 = 0.1 249 16
= 0 5 16 = 0.249 16 = 0.1745D 16 = 0, 1 16
= 0.4 16 = 0.2 16 = 0.1 5 16 = 0.1 16

Negative numbers

Negative numbers can also be displayed. In most cases, the two's complement representation is used for this. Due to their design, no changes need to be made to the mechanisms for calculations in the basic arithmetic operations.

application

Computer science

The hexadecimal system is very suitable for representing sequences of bits (used in digital technology ). Four digits of a bit sequence (a nibble , also called a tetrad) are interpreted like a binary number and thus correspond to a digit in the hexadecimal system, since 16 is the fourth power of 2. The hexadecimal representation of the bit sequences is easier to read and faster to write:

                                  Binär      Hexadezimal           Dezimal
                                   1111  =             F  =             15
                                 1.1111  =            1F  =             31
                      11.0111.1100.0101  =          37C5  =         14.277
                    1010.1100.1101.1100  =          ACDC  =         44.252
                  1.0000.0000.0000.0000  =        1.0000  =         65.536
1010.1111.1111.1110.0000.1000.0001.0101  =     AFFE.0815  =  2.952.661.013

In this illustration, the point is only used to group numbers .

Software therefore often represents machine language in this way.

mathematics

Since the Bailey-Borwein-Plouffe formula for calculating π was developed in 1995, the hexadecimal system has also been important beyond computer science. This sum formula can calculate any hexadecimal digit of π without needing the preceding digits.

Conversion to other number systems

Many pocket calculators , but also the similarly named auxiliary programs on personal computers , offer conversions for changing the number base . In particular, the Windows and macOS programs “Calculator” calculate binary, hexadecimal and octal numbers into decimals and back if you select the menu item “Programmer” under “View” (Windows) or “Display” (macOS). Many Linux distributions come pre-installed with a calculator utility that includes such a “programmer option”, or you can use the printf command on the command line (as a built-in bash command or a separate utility).

Conversion of decimal numbers into hexadecimal numbers

One way of converting a number in the decimal system into a number in the hexadecimal system is to consider the division remainders that arise when the number is divided by the base 16; the method is therefore also called the division method or the residual value method.

In the example of the 1278 10 it would look like this:

1278 : 16 = 79 Rest: 14 (= E) (Nr:1278-(79*16)=14)
  79 : 16 =  4 Rest: 15 (= F) (Nr:79-(4*16)=15)
   4 : 16 =  0 Rest:  4       (Nr:4-(0*16)=4)

The hexadecimal number is read from bottom to top and thus gives 4.FE .

Conversion of hexadecimal numbers into decimal numbers

To convert a hexadecimal number into a decimal number , you have to multiply the individual digits by the respective power of the base . The exponent of the base corresponds to the place of the digit, whereby a zero is assigned to the number before the decimal point. To do this, however, you have to convert the digits A, B, C, D, E, F into the corresponding decimal numbers 10, 11, 12, 13, 14, 15.

Example for 4FE 16 :

Conversion from hexadecimal to octal

In order to convert numbers between the octal system, which used to be common in computer science, and the hexadecimal system used today, it is advisable to take the intermediate step using the binary system. This is quite easy, since both base 8 and base 16 are powers of two.

  • The hexadecimal number is converted into a sequence of binary digits according to the table above.
  • Convert the groups of four into groups of three.
  • The binary sequence is then translated into an octal sequence.

Example for 8D53 16 :

Conversion from octal to hexadecimal

The conversion from octal to hexadecimal is just as easy, only here is the way

Octal sequence → binary sequence in groups of three → binary sequence in groups of four → hexadecimal sequence

is gone.

Mathematical representation of the hexadecimal system

Formulated in the decimal system:

Formulated in the hexadecimal system:

One- and two-handed counting with the fingertips and joints

Like the old Babylonian sexagesimal system, the hexadecimal system can also be counted with the fingers. The following technique is used to represent a byte with both hands together . Each hand represents a nibble . Its upper crumb shows on the used finger, while its lower crumb shows on the indicated joint or the fingertip. A bit flip can be brought about by mirroring the thumb position at the center of the finger surface.

One-handed counting from zero to F 16

OK sign

If, like the ancient Babylonians, you use the thumb as a pointer and place it on the tip of the index finger, as with the OK sign of divers, and define this sign as the zero. Then you can define one on the upper joint of the index finger, followed by two on the middle and finally three on the lower joint. Likewise continued over the four at the tip of the middle finger, the eight at the tip of the ring finger and the twelve on the little one. You can then count to 15 = F 16 when the thumb has reached the lower joint of the little finger, where it has grown.

The two crumbs of the nibble are displayed orthogonally on the hand. So that the lower two bits can be read at the level of the thumb on the respective finger and the two upper bits on the finger in question. This means that both a thumb on the fingertip and on the index finger stand for 00 2 in the respective crumb. The upper joint and the middle finger stand for 01 2 , the middle joint and ring finger stand for 10 2 and the lower joint and the little finger stand for 11 2 . Only four combinations have to be memorized in order to convert manually between the hexadecimal and binary system instead of 16.

A bit flip is easy to achieve by mirroring the position of the thumb at the intersection of the imaginary axes between the ring and middle fingers and the upper and middle row of joints. An example is given at the end of the table below.

Example of converting between hex and binary and bit flips by hand
Whole nibble Upper crumb finger Lower crumb Position of the thumb on the finger
0 16 = (00 00) 2 00 2 index finger 00 2 Great, ok sign
1 16 = (00 01) 2 00 2 index finger 01 2 Upper joint
2 16 = (00 10) 2 00 2 index finger 10 2 Middle joint
3 16 = (00 11) 2 00 2 index finger 11 2 Lower joint
4 16 = (01 00) 2 01 2 Middle finger 00 2 top
8 16 = (10 00) 2 10 2 Ring finger 00 2 top
C 16 = (11 00) 2 11 2 pinkie finger 00 2 top
Bit flip of 2 16 through point mirroring at the intersection of the aforementioned axes
D 16 = (11 01) 2 11 2 pinkie finger 01 2 Upper joint

Two-handed counting from zero to FF 16

If you now count on the left hand with the procedure described above how often you have counted up to F 16 on the right hand , a byte can be represented with two hands. Since four elements are counted on each finger, it follows that multiples of four appear on the fingertips. This means that when the thumbs of the respective hands start to count at zero on the respective index finger tip, the value on the tips of the fingers of the right hand increases by four, whereas when counting over the fingertips of the left hand it increases by 40 16 or 64 increased. If the left hand is only moved forward or backward by a phalanx, the displayed value changes by 10 16 or 16.

See also

Web links

Wiktionary: Hexadecimal system  - explanations of meanings, word origins, synonyms, translations

Individual evidence

  1. Conversion with different base values , accessed on October 30, 2018