In mathematics and computer science, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F (or alternatively a through f) to represent values ten to fifteen. For example, the hexadecimal number 2AF3 is equal, in decimal, to (2 × 163) + (10 × 162) + (15 × 16) + 3, or 10,995.
Each hexadecimal digit represents four binary digits (bits) (also called a "nibble"), and the primary use of hexadecimal notation is as a human-friendly representation of binary coded values in computing and digital electronics. For example, byte values can range from 0 to 255 (decimal) but may be more conveniently represented as two hexadecimal digits in the range 00 through FF. Hexadecimal is also commonly used to represent computer memory addresses.
In situations where there is no context, a hexadecimal number might be ambiguous and confused with numbers expressed in other bases. There are several conventions for expressing values unambiguously. A numerical subscript (itself written in decimal) can give the base explicitly: 15910 is decimal 159; 15916 is hexadecimal 159, which is equal to 34510. Other authors prefer a text subscript, such as 159decimal and 159hex, or 159d and 159h.
In linear text systems, such as those used in most computer programming environments, a variety of methods have arisen:
%: http://www.example.com/name%20with%20spaces where %20 is the space (blank) character (code value 20 in hex, 32 in decimal).ode;, where code is the 1- to 6-digit hex number assigned to the character in the Unicode standard. Thus ’ represents the curled right single quote (Unicode value 2019 in hex, 8217 in decimal).#: white, for example, is represented #FFFFFF .[1] CSS allows 3-hexdigit abbreviations with one hexdigit per component: #FA3 abbreviates #FFAA33 (a golden orange).0x for numeric constants represented in hex: 0x5A3. Character and string constants may express character codes in hexadecimal with the prefix \x followed by two hex digits: '\x1B' represents the Esc control character; "\x1B[0m\x1B[25;1H" is a string containing 11 characters (plus a trailing NUL to mark the end of the string) with two embedded Esc characters.[3] To output an integer as hexadecimal with the printf function family, the format conversion code %X or %x is used.U+ followed by the hex value: U+20AC is the Euro sign (€).=, as in Espa=F1a to send "España" (Spain). (Hexadecimal F1, equal to decimal 241, is the code number for the lower case n with tilda in the ISO/IEC 8859-1 character set.)FFh or 05A3H. Some implementations require a leading zero when the first hexadecimal digit character is not a decimal digit: 0FFh$ as a prefix: $5A3.H'ABCD' (for ABCD16).16#5A3#. VHDL also supports x"5A3".8'hFF, where 8 is the number of bits in the value and FF is the hexadecimal constant.#05A316r: 16r5A316#: 16#5A3. Binary data (such as image pixels) can be expressed as unprefixed consecutive hexadecimal pairs: AA213FD51B3801043FBC...#x and #16r.&H: &H5A3& for hex.[4]0h prefix: 0h5A3X'5A3' are sometimes seen, such as in PL/I. This is the most common format for hexadecimal on IBM mainframes (zSeries) and midrange computers (iSeries) running traditional OS's (zOS, zVSE, zVM, TPF, OS/400), and is used in Assembler, PL/1, Cobol, JCL, scripts, commands and other places. This format was common on other (and now obsolete) IBM systems as well.There is no universal convention to use lowercase or uppercase for the letter digits, and each is prevalent or preferred in particular environments by community standards or convention.