
Hexadecimal (hex for short) is a positional numeral system for representing a numeric value as base 16. For the most common convention, a digit is represented as "0" to "9" like for decimal and as a letter of the alphabet from "A" to "F" (either upper or lower case) for the digits with decimal value 10 to 15.
As typical computer hardware is binary in nature and that hex is power of 2, the hex representation is often used in computing as a dense representation of binary information. A hex digit represents 4 contiguous bits known as a nibble.[1] An 8-bit byte is two hex digits, such as .
Special notation is often used to indicate that a number is hex. In mathematics, a subscript is typically used to specify the base. For example, the decimal value would be expressed in hex as . In computer programming, various notations are used. In C and many related languages, the prefix 0x is used. For example, 0x{{hexadecimal|491|no}}.
Typically, a hex representation convention allows either lower or upper case letters and treats the letter the same regardless of its case.
Often when rendering non-textual data, a value stored in memory is displayed as a sequence of hex digits with spaces between values. For instance, in the following hex dump, each 8-bit byte is a 2-digit hex number, with spaces between them, while the 32-bit offset at the start is an 8-digit hex number.
There are several conventions for expressing that a number is represented as hex.
0x indicates that the numeric literal after it is in hex, a character of a string or character literal can be expressed as hex with the prefix \x (for example '\x1B' represents the Esc control character) and to output an integer as hex via printf-like function, the format conversion code %X or %x is used