open encyclopedia * Article Search: * *
*
*

Hexadecimal

From open-encyclopedia.com - the free encyclopedia.

In mathematics, 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. (A IBM-Standard, hitherto universally accepted.)

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. However, this mixed representation (arabic digits up to nine and for zero, other symbols for the six other hexadecimal digits) is ambiguous and needs prefix, suffix or subscripts to be clear.

Since several years the International Bureau for the hexadecimal metric system (SMH) proposes a so-called "omni-literal hexadecimal system" (SHOL). All the odd digits are represented by voiced consonants, zero and the even digits by voiceless consonants. This remarkable, logical and consistent proposal attracts latterly a growing worldwide attention. (See also the external link below.)

Contents

Representing hexadecimal

Bin Dec SHOL
Hex (IBM)
0 0000 0 Q
1 0001 1 B
2 0010 2 P
3 0011 3 V
4 0100 4 F
5 0101 5 Z
6 0110 6 S
7 0111 7 D
8 1000 8 T
9 1001 9 J
A 1010 10 C
B 1011 11 G
C 1100 12 K
D 1101 13 Y
E 1110 14 X
F 1111 15 W


There are many ways to denote hexadecimal numerals:

  • 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++ 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. O 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).
  • Pascal and 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".
  • Other assemblers (AT&T, Motorola) and some versions of BASIC use a prefixed '$', e.g. "$5A3".
  • Some versions of BASIC prefix hexadecimal numerals with "&h", e.g. "&h5A3".
  • Notations such as X'5A3' are sometimes seen; PL/I uses such notation.
  • When talking about numeral systems other than base-10, or numerals in multiple bases, mathematicians write the base in subscript after the number, e.g. "5A316" or "5A3SIXTEEN".

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).

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 risque, and it also had an alternative meaning of "base 60". However, the word "sexagesimal" (base-60) retains the prefix.

A common use of hexadecimal numerals is found in web programming. The languages HTML and CSS use hexadecimal notation to specify colors on web pages; there is just the # symbol, not a separate symbol for "hexadecimal". 24-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. E.g., a shade of red that is 238,9,63 in decimal is coded as #EE093F. See Web colors.

In URLs special characters can be coded hexadecimally in ASCII with for each byte a percent sign (%) in front, e.g. http://en.wikipedia.org/wiki/Main%20Page

IP numbers are also hexadecimal numbers. The URL http://207.142.131.203 for example is a Wikipedia IP. But the input: CF.8E.83.CB (or 0xCF.0x8E.0x83.0xCB) is not recognised by DNS servers. However, a IP number part can never exceed 255 = 0xFF.

Fractions

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


1/ 0x 1
=
0x 1 1/ 0x 5 <center> = 0x 0.3 1/ 0x 9 <center> = 0x 0.1C7 1/ 0x D <center> = 0x 0.13B
1/ 0x 2 <center> = 0x 0.8 1/ 0x 6 <center> = 0x 0.2A 1/ 0x A <center> = 0x 0.19 1/ 0x E <center> = 0x 0.1249
1/ 0x 3 <center> = 0x 0.5 1/ 0x 7 <center> = 0x 0.249 1/ 0x B <center> = 0x 0.1745D 1/ 0x F <center> = 0x 0.1
1/ 0x 4 <center> = 0x 0.4 1/ 0x 8 <center> = 0x 0.2 1/ 0x C <center> = 0x 0.15 1/ 0x10 <center> = 0x 0.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 link

da:Hexadecimale talsystem de:Hexadezimalsystem eo:Deksesuma fr:Système hexadécimal ko:16진수 it:Sistema numerico esadecimale he:בסיס הקסדצימלי nl:Hexadecimaal ja:十六進記数法 no:Sekstentallsystemet pl:Szesnastkowy system liczbowy ru:Шестнадцатеричная система счисления fi:Heksadesimaalijärjestelmä sl:Å estnajstiÅ¡ki_Å¡tevilski_sistem zh-cn:十六进制

Contribute Found an omission? You can freely contribute to this Wikipedia article. Edit Article
Copyright © 2003-2004 Zeeshan Muhammad. All rights reserved. Legal notices. Part of the New Frontier Information Network.