5.3: Binary, Octal, and Hexadecimal
- Page ID
- 55946
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)In modern computing and digital electronics, the most commonly used bases are decimal (base 10), binary (base 2), octal (base 8), and hexadecimal (base 16). If we are converting between two bases other than decimal, we typically have to convert the number to base 10 first, and then convert that number to the second base. However, we can easily convert directly from binary to octal, and vice versa, and from binary to hexadecimal, and vice versa.
This video gives a basic introduction to these conversions:
For another description, this one is more like a math lecture:
For further clarification, recall that the numbers 0 through 7 can be represented by up to three digits in base two. In base eight, these numbers are represented by a single digit.
Base 2 (binary) number | Base 10 (decimal) equivalent | Base 8 (octal) number |
---|---|---|
000 | 0 | 0 |
001 | 1 | 1 |
010 | 2 | 2 |
011 | 3 | 3 |
100 | 4 | 4 |
101 | 5 | 5 |
110 | 6 | 6 |
111 | 7 | 7 |
Now when we get to the number 8, we need four digits in base 2 and two digits in base 8. In fact, the numbers 8 through 63 can be represented by two digits in base 8. We need four, five, or six digits in base 2 to represent these same numbers:
Base 2 number | Base 10 equivalent | Base 8 number |
---|---|---|
1000 | 8 | 10 = 1 × 8 + 0 × 1 |
1001 | 9 | 11 = 1 × 8 + 1 × 1 |
1010 | 10 | 12 = 1 × 8 + 2 × 1 |
… | … | … |
111100 | 60 | 74 = 7 × 8 + 4 × 1 |
111101 | 61 | 75 = 7 × 8 + 5 × 1 |
111110 | 62 | 76 = 7 × 8 + 6 × 1 |
111111 | 63 | 77 = 7 × 8 + 7 × 1 |
The number 64 in base 8 is represented by 1008 = 1 × 82 + 0 × 81 + 0 × 80 = 1 × 64 + 0 × 8 + 0 × 1. In base 2, this would be 10000002. Do you see a pattern here? For a single digit in base 8, we need up to three digits in base 2. For two digits in base 8, we need 4, 5, or 6 digits in base 2. For three digits in base 8, we need 7, 8, or 9 digits in base 2. For each additional digit in base 8, we need up to three spaces to represent it in base 2. Here’s a way to remember this: 23 = 8, so we need three spaces.
A couple of examples would help here.
- Convert the number 61578 to base 2. We split each digit in base 8 to three digits in base 2, using the three digit base 2 equivalent, so 68 = 1102, 18 = 0012, etc.
- Convert the number 101110110010102 to base 8. Split this number into sets of three, starting with the right-most digit, then convert each set of three to its equivalent in base 8.
For hexadecimal (base 16), we need up to four digits in binary to represent each single digit. Remember this by recalling that 24 = 16, so we need four digits.
You may want to print out copies of these worksheets to help you with your conversions between binary and octal or hexadecimal:
If you would like to quiz yourself on converting the numbers 0 through 255 to binary, octal, and hexadecimal (and between those bases), here’s a link to the representations of those numbers: Binary, Octal, and Hexadecimal Numbers.
- Mathematics for the Liberal Arts I. Provided by: Extended Learning Institute of Northern Virginia Community College. Located at: http://eli.nvcc.edu/. License: CC BY: Attribution
- Pre-Algebra 3 - Decimal, Binary, Octal & Hexadecimal. Authored by: MyWhyU. Located at: https://youtu.be/5sS7w-CMHkU. License: All Rights Reserved. License Terms: Standard YouTube License
- Binary, Hexadecimal, Octal conversion. Authored by: Joey Lawrance. Located at: https://youtu.be/2UwxdCLFW70. License: All Rights Reserved. License Terms: Standard YouTube License