Skip to main content
Engineering LibreTexts

14.5: Negative Numbers

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

    To know the value of a positive number is simple: we just add all the powers of 2 given by the binary representation as explained at the beginning of this chapter. Getting the value of a negative number is quite simple: we do the same except that we count the sign bit as negative and all the other ones as positive. The sign bit is the most significant bit i.e., the bit that represents the largest value (see Figure \(\PageIndex{1}\)). For example, on 8 bit representation it will be the one associated with the weight \( 2^7 \).

    Negative numbers in 8 bits.
    Figure \(\PageIndex{1}\): Negative numbers on 8 bits.

    Let us illustrate that: −2 is represented on 8 bit encoding as: 1111 1110.

    To get the value out of the bit representation, we simple add: \( -2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 0 * 2^0 \), i.e., \( -128 + 64 + 32 + 16 + 8 + 4 + 2 \) and we get \( -2 \).

    \( -69 \) is represented on 8 bit encoding as: \( 1011 1011 \). To get the value out of the bit representation is simple. We add \( -2^7 + 0 * 2^6 + 2^5 + 2^4 + 2^3 + 0 * 2^2 + 2^1 + 2^0 \), i.e., \( -128 + 32 + 16 + 8 + 2 + 1 \) and we get \( -69 \).

    Following the same principle, check that the value of \( -1 \) is the one described in Figure \(PageIndex{1}\).

    Let us count a bit: on an 8 bit representation we can then encode 0 to 255 positive integers or -128 to \( 64 + 32 + 16 + 8 + 4 + 2 + 1 \) 127. In fact we can encode from \( -1 * 2^7 \) to \( 2^7 - 1 \). More generally on \( N \) bit we can encode \( -1 * 2^{N-1} - 1 \) integer values.


    This page titled 14.5: Negative Numbers is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Alexandre Bergel, Damien Cassou, Stéphane Ducasse, Jannik Laval (Square Bracket Associates) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.