Template:Table Numeral Systems In mathematics and computer science, hexadecimal or simply hex is a numeral system with a radix or base of 16 usually written using the symbols 0–9 and A–F or a–f. The hexadecimal system was first introduced to the computing world in 1963 by IBM.

For example, the decimal numeral 79 whose binary representation is 01001111 can be written as 4F in hexadecimal (4 = 0100, F = 1111).

It is a useful system in computers because there is an easy mapping from four bits to a single hex digit. A byte can be represented as two consecutive hexadecimal digits.

It was IBM that decided on the prefix of "hexa" rather than the proper Latin but more politically incorrect prefix of "sexa". The word "hexadecimal" is strange in that hexa is derived from the Greek έξι (hexi) for "six" and decimal is derived from the Latin for "ten". An older term was the pure Latin "sexidecimal", but that was changed because some people thought it too risqu, and it also had an alternative meaning of "base 60". However, the word "sexagesimal" (base-60) retains the prefix.


Representing hexadecimal

Hex Bin Dec
0 0000 0
1 0001 1
2 0010 2
3 0011 3
4 0100 4
5 0101 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
A 1010 10
B 1011 11
C 1100 12
D 1101 13
E 1110 14
F 1111 15

Some hexadecimal numbers are indistinguishable from a decimal number (to both humans and computers). Therefore, some convention is usually used to flag them.

In typeset text, the indication is often a subscripted suffix such as 5A316, 5A3SIXTEEN, or 5A3HEX.

In computer programming languages (which are nearly always without such typographical distinctions as subscript and superscript) a wide variety of ways of marking hexadecimal numbers have appeared. (These are also seen even in typeset text.)

Some of the more common textual representations:

  • Ada and VHDL enclose hexadecimal numerals in based "numeric quotes", e.g. "16#5A3#". (Note: Ada accepts this notation for all bases from 2 through 16 and for both integer and real types.)
  • C and languages with a similar syntax (such as C++, C# and Java) prefix hexadecimal numerals with "0x", e.g. "0x5A3". The leading "0" is used so that the parser can simply recognize a number, and the "x" stands for hexadecimal (c.f. 0 for Octal). The "x" in "0x" can be either in upper or lower case.
  • In HTML, hexadecimal character references also use the x: ֣ should give the same as ֣ – with your browser ֣ and ֣ respectively (Hebrew accent munah).
  • Some assemblers indicate hex by an appended "h" (if the numeral starts with a letter, then also with a preceding 0), e.g., "0A3Ch", "5A3h".
  • Postscript indicates hex by a prefix "16#".
  • Common Lisp use the prefixes "#x" and "#16r".
  • Pascal, other assemblers (AT&T, Motorola), and some versions of BASIC use a prefixed "$", e.g. "$5A3".
  • Some versions of BASIC, notably Microsoft's variants including QBasic and Visual Basic), prefix hexadecimal numerals with "&H", e.g. "&H5A3"; others such as BBC BASIC just used "&" (used for octal in Microsoft's BASIC!).
  • Notations such as X'5A3' are sometimes seen; PL/I uses such notation.

There is no single agreed-upon standard, so all the above conventions are in use, sometimes even in the same paper. However, as they are quite unambiguous, little difficulty arises from this.

The most commonly used (or encountered) notations are the ones with a prefix "0x" or a subscript-base 16, for hex numbers. For example, both 0x2BAD and 2BAD16 represent the decimal number 11181 (or 1118110).

Missing image
A hexadecimal multiplication table


A common use of hexadecimal numerals is found in HTML and CSS. They use hexadecimal notation (hex triplets) to specify colours on web pages; there is just the # symbol, not a separate symbol for "hexadecimal". Twenty-four-bit color is represented in the format #RRGGBB, where RR specifies the value of the Red component of the color, GG the Green component and BB the Blue component. For example, a shade of red that is 238,9,63 in decimal is coded as #EE093F. This syntax is borrowed from the X Window System.

In URLs, special characters can be coded hexadecimally, with a percent sign used to introduce each byte; e.g., http://en.wikipedia.org/wiki/Main%20Page

The canonical written form of numeric IPv6 addresses represents each group of 16 bits as a separate hexadecimal number, to ease reading and transcription of the 128-bit addresses.


As with other numeral systems, the hexadecimal system can be used in forming vulgar fractions, although recurring digits are common:

1/ 0x1
0x1 1/ 0x5 <center> = 0x0.3 1/ 0x9 <center> = 0x0.1C7 1/ 0xD <center> = 0x0.13B
1/ 0x2 <center> = 0x0.8 1/ 0x6 <center> = 0x0.2A 1/ 0xA <center> = 0x0.19 1/ 0xE <center> = 0x0.1249
1/ 0x3 <center> = 0x0.5 1/ 0x7 <center> = 0x0.249 1/ 0xB <center> = 0x0.1745D 1/ 0xF <center> = 0x0.1
1/ 0x4 <center> = 0x0.4 1/ 0x8 <center> = 0x0.2 1/ 0xC <center> = 0x0.15 1/ 0x10 <center> = 0x0.1

Because the radix 16 is a square (42), hexadecimal fractions have an odd period much more often than decimal ones. Recurring decimals occur when the denominator in lowest terms has a prime factor not found in the radix. In the case of hexadecimal numbers, all fractions with denominators that are not a power of two will result in a recurring decimal.

See also

External links


da:Hexadecimale talsystem de:Hexadezimalsystem es:Sistema hexadecimal eo:Deksesuma fr:Systme hexadcimal ko:십육진법 it:Sistema numerico esadecimale he:בסיס הקסדצימלי nl:Hexadecimaal ja:十六進記数法 no:Sekstentallsystemet pl:Szesnastkowy system liczbowy pt:Sistema hexadecimal ru:Шестнадцатеричная система счисления sl:Šestnajstiški številski sistem fi:Heksadesimaalijrjestelm sv:Hexadecimalsystemet th:เลขฐานสิบหก


  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)


  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Personal tools