https://www.techtarget.com/whatis/definition/hexadecimal
Hexadecimal is a numbering system that uses a base-16 representation for numeric values. It can be used to represent large numbers with fewer digits. This system has 16 symbols, or possible digit values 0-9, followed by six alphabetic characters: A, B, C, D, E and F. These characters represent decimal values 10-15 in single bits.
Hexadecimal -- also known as base-16 or hex -- is one of four numbering systems. The other three are decimal, or base-10; binary, or base-2; and octal, or base-8.
The following conversion table illustrates the decimal and hexadecimal systems for digits 0-15:
Decimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Hexadecimal | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Decimal | 10 | 11 | 12 | 13 | 14 | 15 |
Hexadecimal | A | B | C | D | E | F |
The hexadecimal system uses different numbers than its decimal numbering system counterpart. In the hexadecimal system, 16 sequential numbers, including 0, are used as base units. The first nine numbers, 0-9, are the same ones commonly used in the decimal system. The next six two-digit numbers, 10-15, are represented by the letters A-F. This is how the hex system uses the numbers 0-9 and the capital letters A-F to represent the equivalent decimal number.
In this numbering system, each digit's position is 16 times more significant than the digit in the previous position. The hex number starts with the least significant digit on the right-hand side. The numeric value of this number is calculated by multiplying each digit by the value of its position and then adding the products. This is why hexadecimal is a positional or weighted number system.
In computing systems, the binary string equivalents of large decimal numbers can become quite long. When 16- or 32-bit numbers are involved, reading and writing them without producing errors becomes difficult. These problems can be overcome by arranging the binary numbers into groups of four bits using the hexadecimal numbering system.
The format of hex numbers is more compact than binary numbers because they can represent large binary numbers with fewer digits. As a result, they're easier to understand than long binary strings of 1s and 0s.
Programmers use hex because its numeric values are significantly shorter than if they were expressed in decimal format. This is why many computer error codes and memory addresses are represented in hexadecimal format, and why understanding these hexadecimal numerical expressions is essential in computer software debugging. Hex numerical expressions are also found in blue screen of death stop codes and Hypertext Markup Language (HTML) color codes.
A single hex digit can represent four digits of a binary number. Dividing a binary number into 4-bit sets means each set can have a possible value between 0000 and 1111, allowing for 16 number combinations from 0 to 15. With the base value of 16, the maximum value of a digit is 15.
It's easy to convert a binary number into a hexadecimal number and to execute a binary conversion from hexadecimal. The following table shows how these numbers are represented in each system:
Hexadecimal number | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
4-bit binary number | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 |
Hexadecimal number | 8 | 9 | A | B | C | D | E | F |
4-bit binary number | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
Additionally, the digits to the left of the decimal point represent a value that's calculated by raising base-16 to the corresponding power. This results in weights of 160, 161, 162 and so on. Similarly, the numbers to the right of the decimal point have weights of 16-1, 16-2 and so on.
To represent the decimal number 512 in hex:
Decimal value = 512
512 = 2x162 + 0x161 + 0x160 = 200
Hex value = 200
To change a binary number decimal equivalent to a hexadecimal conversion, four binary digits must be mapped or converted to one hexadecimal digit. The following steps show how the conversion works:
The following steps can be used to convert the binary number 1011010101100001 to hex form:
1011 | 0101 | 0110 | 0001 |
1011 | 0101 | 0110 | 0001 |
B | 5 | 6 | 1 |
10110101011000012 = B56116
The following steps can be used to convert a decimal number to hexadecimal:
The hexadecimal value obtained is the sequence of remainders from the last to the first.
The following steps can be used to convert the decimal number 1128 to hexadecimal:
The result: 112810 = 46816.
Hexadecimal numbers are usually prefixed or suffixed with identifiers to avoid confusion during reading or writing and to make it easier to distinguish hex numbers from decimal numbers. Some common hex identifiers include the following:
Identifier | Usage | Example |
% | Commonly used in URLs to specific characters like spaces | %2 |
# | Used in HTML language as color reference | #RR5687 |
0h | Used in programmable graphic calculators | 0h7D |
\x | Used in HTML, Extensible Markup Language and other languages to express character control codes | \x08: Backspace \x1B: Escape |
0x | Used in Unix and C-based programming | 0x54EF |
Other identifiers are also available; however, they are usually limited to specific programming languages and can't be used interchangeably with other languages.
Programmers can access online hexadecimal-to-decimal conversion tools, such as BinaryHexConverter, which makes working with hex numerals easier.
The hexadecimal numerical system is particularly useful in computer programming and microprocessors. Developers use it to describe colors on webpages, describe memory locations for each byte, specify certain characters and more. Hex numbers are also used in microcontrollers to simplify data handling and manipulation. Other possible applications are data science and analytics, as well as machine learning and artificial intelligence (AI).
Hex numbers are compact and use less memory, so more numbers can be stored in computer systems. Their small size also makes input/output handling easier compared with other numbering formats. Because it's easy to convert hexadecimal to the binary number system and vice versa, the system is widely used in computer programming. It's also useful to represent computer memory addresses.
One drawback of the hexadecimal system is that it can be challenging to perform complex mathematical operations like multiplication and division. Hex numbers are also difficult to read and write compared with decimal numbers.
From the 1960s through the 1980s, it was common to find computer programmers who could read hex dumps of numbers when they had to debug a malfunctioning system, especially when working with older programming languages like Assembler.
Hexadecimal is used in the following applications:
Explore how binary and decimal conversions are important for networking. Learn how to make these conversions for IPv4 addressing, subnet masks and network IDs.
20 Feb 2025