Octal And Hexadecimal

The octal numbering system is sometimes used in computing, but the hexadecimal system, or  base-16 numbering system, is more common.  It is based on 16 digits.  As there are only 10 decimal digits, 0, 1, …, 9, in a 16-digit system, additional characters must be used.  In hexadecimal numbering, these characters are uppercase letters, starting with “A” and ending with
“F”.  That is, the hexadecimal digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.  That is, hexadecimal digits: 0 – 9 denote decimal digits 0 – 9, and hexadecimal digits A – F denote decimal digits 10 – 15.  Since 16 = 24, binary numbers can be easily converted to hexadecimal by grouping the binary number into groups of 4 bits, each 4-bit number representing a hexadecimal digit.  Hexadecimal numbers are often distinguished from other numbering systems by the 16 subscript, or, more commonly in computer science, by “h” or “H”.  The previous example, 1011 11002, is represented as BC in hexadecimal.  Since 10112 = 1110 = B16 = BH, and 11002 = 1210 = C16 = CH.  Converting BCH to decimal is also straightforward.  BCH = (11 x 161) + (12 x 160) = 176 + 12 = 188, as was shown in the decimal conversion for binary above.

 

As another example, the hexadecimal number FACE16 =  (15 x 163) + (10 x 162) + (12 x 161) + (14 x 160) = 64206.  Alternatively, the number can be converted easily to binary, and then to decimal, if necessary.  FACE16 = 1111 1010 1100 11102.  Note that because 16 = 24, a hexadecimal number with h digits has 4 x h bits.

 

Hexadecimal numbers are commonly used to represent RGB colours (colours using the “Red, Green, Blue” colour model).  This colour model will be described in detail in a subsequent section.  For now, it suffices to note that these hexadecimal number are prefaced with a “#” symbol, especially in program code and HTML, and that two hexadecimal digits represent a single 8-bit colour.  For example, the each of the three RGB components in the colour “blue” (Red = 0, Green = 0, Blue = 255 in an 8-bit representation) is denoted in binary.  For “blue”, this yields R = 0000 0000, G = 0000 0000, B = 1111 1111, and therefore the hexadecimal representation of “blue” is #0000FF.  For the colour “yellow”, R = 255, G = 255, B = 0, and therefore, in hexadecimal, yellow is represented as #FFFF00.  From tables of colours (e.g. Web Colours), it is seen that “Sienna” has RGB value R = 160, G = 82, G = 45.  To convert to hexadecimal, the R, G, and B components will first be converted to binary.

 

For the R component, 160 = 128 + 32 = 27 + 25 = 101000002 = 1010 00002 = A0H.

For the G component, 82 = 64 + 16 + 2 = 26 + 24 + 21 = 10100102 = 0101 00102 = 52H.

For the B component, 45 = 32 + 8 + 4 + 1 = 25 + 23 + 22  + 20 = 1011012 = 0010 11012 = 2DH.

 

Therefore, the colour “sienna” is represented in hexadecimal as #A0522D.

 

[NEXT]

License

Icon for the Creative Commons Attribution-ShareAlike 4.0 International License

Contemporary Digital Humanities Copyright © 2022 by Mark P. Wachowiak is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book