Skip to main content
Mathematics LibreTexts

3.1: Binary Representations

  • Page ID
    22650
  • \( \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}\)

    Suppose \(\left\{a_{n}\right\}_{n=1}^{\infty}\) is a sequence such that, for each \(n=1,2,3, \ldots,\) either \(a_{n}=0\) or \(a_{n}=1\) and, for any integer \(N,\) there exists an integer \(n>N\) such that \(a_{n}=0 .\) Then

    \[0 \leq \frac{a_{n}}{2^{n}} \leq \frac{1}{2^{n}}\]

    for \(n=1,2,3, \dots,\) so the infinite series

    \[\sum_{n=1}^{\infty} \frac{a_{n}}{2^{n}}\]

    converges to some real number \(x\) by the comparison test. Moreover,

    \[0 \leq x<\sum_{n=1}^{\infty} \frac{1}{2^{n}}=1.\]

    We call the sequence \(\left\{a_{n}\right\}_{n=1}^{\infty}\) the binary representation for \(x,\) and write

    \[x=.a_{1} a_{2} a_{3} a_{4} \dots.\]

    Exercise \(\PageIndex{1}\)

    Suppose \(\left\{a_{n}\right\}_{n=1}^{\infty}\) and \(\left\{b_{n}\right\}_{n=1}^{\infty}\) are both binary representations for \(x .\) Show that \(a_{n}=b_{n}\) for \(n=1,2,3, \ldots\).

    Now suppose \(x \in \mathbb{R}\) with \(0 \leq x<1\). Construct a sequence \(\left\{a_{n}\right\}_{n=1}^{\infty}\) as follows: If \(0 \leq x<\frac{1}{2},\) let \(a_{1}=0 ;\) otherwise, let \(a_{1}=1 .\) For \(n=1,2,3, \ldots,\) let

    \[s_{n}=\sum_{i=1}^{n} \frac{a_{i}}{2^{i}}\]

    and set \(a_{n+1}=1\) if

    \[s_{n}+\frac{1}{2^{n+1}} \leq x\]

    and \(a_{n+1}=0\) otherwise.

    lemma \(\PageIndex{1}\)

    With the notation as above,

    \[s_{n} \leq x<s_{n}+\frac{1}{2^{n}}\]

    for \(n=1,2,3, \ldots\).

    Proof

    Since

    \[s_{1}=\left\{\begin{array}{ll}{0,} & {\text { if } 0 \leq x<\frac{1}{2}} \\ {\frac{1}{2},} & {\text { if } \frac{1}{2} \leq x<1}\end{array}\right.\]

    it is clear that \(s_{1} \leq x<s_{1}+\frac{1}{2} .\) So suppose \(n>1\) and \(s_{n-1} \leq x<s_{n-1}+\frac{1}{2^{n-1}}\). If \(s_{n-1}+\frac{1}{2 n} \leq x,\) then \(a_{n}=1\) and

    \[s_{n}=s_{n-1}+\frac{1}{2^{n}} \leq x<s_{n-1}+\frac{1}{2^{n-1}}=s_{n-1}+\frac{1}{2^{n}}+\frac{1}{2^{n}}=s_{n}+\frac{1}{2^{n}}.\]

    If \(x<s_{n-1}+\frac{1}{2^{n}},\) then \(a_{n}=0\) and

    \[s_{n}=s_{n-1} \leq x<s_{n-1}+\frac{1}{2^{n}}=s_{n}+\frac{1}{2^{n}}.\]

    Q.E.D.

    Proposition \(\PageIndex{2}\)

    With the notation as above,

    \[x=\sum_{n=1}^{\infty} \frac{a_{n}}{2^{n}}.\]

    Proof

    Given \(\epsilon>0,\) choose an integer \(N\) such that \(\frac{1}{2^{n}}<\epsilon .\) Then, for any \(n>N,\) it follows from the lemma that

    \[\left|s_{n}-x\right|<\frac{1}{2^{n}}<\frac{1}{2^{N}}<\epsilon .\]

    Hence

    \[x=\lim _{n \rightarrow \infty} s_{n}=\sum_{n=1}^{\infty} \frac{a_{n}}{2^{n}}.\]

    Q.E.D.

    lemma \(\PageIndex{3}\)

    With the notation as above, given any integer \(N\) there exists an integer \(n>N\) such that \(a_{n}=0\).

    Proof

    If \(a_{n}=1\) for \(n=1,2,3, \dots,\) then

    \[x=\sum_{n=1}^{\infty} \frac{1}{2^{n}}=1,\]

    contradicting the assumption that \(0 \leq x<1 .\) Now suppose there exists an integer \(N\) such that \(a_{N}=0\) but \(a_{n}=1\) for every \(n>N .\) Then

    \[x=s_{N}+\sum_{n=N+1}^{\infty} \frac{1}{2^{n}}=s_{N-1}+\sum_{n=N+1}^{\infty} \frac{1}{2^{n}}=s_{N-1}+\frac{1}{2^{N}},\]

    implying that \(a_{N}=1,\) and thus contradicting the assumption that \(a_{N}=0\). \(\quad\) Q.E.D.

    Combining the previous lemma with the previous proposition yields the following result.

    Proposition \(\PageIndex{4}\)

    With the notation as above, \(x=. a_{1} a_{2} a_{3} a_{4} \ldots\).

    The next theorem now follows from Exercise 3.1.1 and the previous proposition.

    Theorem \(\PageIndex{5}\)

    Every real number \(0 \leq x<1\) has a unique binary representation.


    This page titled 3.1: Binary Representations is shared under a CC BY-NC-SA 1.0 license and was authored, remixed, and/or curated by Dan Sloughter via source content that was edited to the style and standards of the LibreTexts platform.