Skip to content

Hexadecimal Values

Understand how base 16 (hex) number system is a shorthand to base 2 (binary)

Key Concepts

Base 16 is a compact means to representing binary valuesWith a little understanding, hardware and software practitioners can translate between Hex and Binary
Hexadecimal and Binary have a helpful association16 is a power of 2...2^4. This property means each 4 binary digits concert to 1 Hex symbol, making conversions a bit simpler
Terms
TermMeaning
BinaryBase 2 numbers.
DecimalBase 10 numbers.
Hex or HexadecimalBase 16 numbers.
Place or Place ValueValue of a single number in multi-symbol value. Example: In the number 12345, the Place Value if the 3 is 300.
SignedNumbers that represent negative, zero, and positive values.
SymbolsWritten characters used to depict numbers. Symbols represent to represent Decimal are 0,1,2,3,4,5,6,7,8,9.
UnsignedNumbers that represent only zero and positive values.

Introduction

What is Base 16?

Base 16 Number System

PropertyValue
# of symbols16
Symbol Range0 - F
Symbols0 1 2 3 4 5 6 7 8 9 A B C D E F
Place Value Factor16

Base 16 (Hexadecimal or Hex) is a number system you will likely encounter in various places in Computer Science. While a bit odd looking at the start, Hex is a shortcut to describing binary values in a compact manner

Converting to Base 10

The algorithm used to convert from Binary to base 10 works here, just changing the base to 16. We also need to use the lookup table (above) to convert each Hex value to Decimal

Convert to Base 10

Algorithm

Recall that number positions in a number string start at zero. So the value in the 1st position is said to be in position 0

Also, we will be raising 16 to the power of the position, because the original number is in Base 16

  1. Convert each Hex value to Base 10 using the lookup table
  2. Multiply the resulting Base 10 value by 16 raised to the power of the value's position
  3. Add the result to the final Decimal result
  4. Repeat for all Hex values

You'll Need a Calculator for this

Raising 16 to increasing powers is not easy to do in your head. And, in the above example, notice each Hex place value grows substantially. This is why Base 16 results in very compact numbers that represent large Decimal values

16^2

Converting to/from Binary

Convert to Base 10

This is where Hex is that compact representation of binary

Each Hex value represent 1 4-bit Binary string. And a 4-bit Binary value can be represented by a single Hex value

BinaryDecimalHexBinaryDecimalHex
000000100088
000111100199
001022101010A
001133101111B
010044110012C
010155110113D
011066111014E
011177111115F

Conclusion

Converting from Hexadecimal to Decimal is the same algorithm and Binary to Decimal, just using a different base number in the conversions.

Hexadecimal is useful in expressing binary values in a compact format. Each Hex symbol represents exactly four (4) binary numbers.

The contents of this E-Text were developed under an Open Textbooks Pilot grant from the Fund for the Improvement of Postsecondary Education (FIPSE), U.S. Department of Education. However, those contents do not necessarily represent the policy of the Department of Education, and you should not assume endorsement by the Federal Government.
Released under Creative Commons BY NC 4.0 International License