Skip to main content
Engineering LibreTexts

2.1: Binary Numbers

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

    2.1.1 Values for Binary Numbers

    Many students will have had a class in CS, Philosophy, or Mathematics covering Logic or Boolean algebra. This class will have used binary values are generally true(T) and false(F) and use special symbols such as "^" for AND and "˅" for OR. This might be fine for mathematics and logic, but is hopelessly inadequate for the engineering task of creating computer machines and languages.

    To begin, the physical implementation of a binary value in a CPU’s hardware, called a bit, is implemented as a circuit called a flip-flop or latch. A flip-flop maintains a voltage of either a ground or a positive supply voltage, which is a voltage over ground, called the Voltage at Common Collector (VCC). If the output voltage of the flip-flip is equal to the ground, the flip-flop stores a logical T; when the output voltage of the flip-flop is VCC, the flip-flop stores a logical value of F. While most older Integrated Circuit (IC) components used +5V VCC for true, many modern ICs use +3.3V VCC. There are many different values that are used for VCC in circuits, some with a VCC less than +1V.

    But the binary values of true and false really only have meaning when representing logical equations. For computation the binary values of 1 (for true) and 0 (for false) are much more common, as these can be combined easily to create larger values. The most prevalent use of binary data in this textbook will be binary values of 0 and 1.

    If a flip-flop maintains a value of 1, it is also called high, since the voltage is positive, and low if the value is 0. If a switch or gate is used, a high voltage is called On or Open, and Off or Closed if the value voltage is low. Thus, while computers work with binary, there are a number of ways we can talk about binary. If the discussion is about memory, the value is high, on, or 1. When the purpose is to describe a gate, it is open/closed. If there are logical operations, values will be true/false. The following table summarizes the binary value naming conventions.

    T/F

    Number

    Switch

    Voltage

    Gate

    F

    0

    Off

    Low

    Closed

    T

    1

    On

    High

    Open

    Table 2-1: Various names for binary values

    In addition to the various names, engineers are more comfortable with arithmetic operators rather than logical operators. This book will follow the engineering convention that "+" is the OR operator, "*" is the AND operator, and "!" (pronounced bang) is the NOT operator.

    Some students are uncomfortable with the ambiguity in the names for true and false. They often feel that the way the binary values were presented in their mathematics or philosophy classes (as true/false) is the "correct" way to represent them. This would be fine if the goal were to create logic equations, equations that resolve to true or false, that are commonly covered in those classes. But this class is about implementing a computer in hardware. There is no correct, or even more correct, way to discuss binary values. How they will be referred to will depend on the way in which the value is being used. Understanding a computer requires the individual to be adaptable to all of these ways of referring to binary values. All of the ways used to represent binary values in Table 2-1 will all be used in this text, though most of the time the binary values of 0 and 1 will be used.


    2.1.2 Binary Whole Numbers

    The numbering system that everyone learned in elementary school is called decimal or base 10 numbers. This numbering system is called decimal because it has 10 digits, [0..9]. Thus quantities up to 9 can be easily referenced in this system by a single number.

    Computers use circuits that produce binary output. This output can be either 0 or 1, and so computers use the binary, or base 2, numbering system. In binary, there are only two digits, 0 and 1. So values up to 1 can be easily represented by a single digit. Having only the ability to represent 0 or 1 items is too limiting to be useful. But then so are the 10 values which can be used in the decimal system. The question is how does the decimal handle the problem of numbers greater than 9, and can binary use the same idea?

    In decimal when adding 1 plus 9 (1+9) the number 10 is created. The number 10 means that there is 1 group of ten values (the digits 0...9), and 0 one values. The number 11 is 1 group of ten and 1 one. When 99 is reached, we have 100, which is 1 group of hundred, 0 groups of tens, and 0 ones. So the number 1,245 would be 1 group of thousands, 2 groups of hundreds, 4 groups of tens, and 5 ones. This can be easily written using exponential format as:

    \(1,245 = 1*10^3 + 2*10^2 + 4*10^1+ 5*10^0\)

    Base 2 can be handled in the same manner. The number \(10_2\) (base 2) is 1 group of two and 0 ones, which corresponds to \(2_{10}\) (2 base 10). Counting in base 2 is the same. To count in base 2, the numbers are \(0_2, 1_2, 10_2, 11_2, 100_2, 101_2, 110_2, 111_2\), etc. Analogously to the base 10 example above, any base 2 number can be represented in exponential format. Thus, the number \(101011_2\) can be represented by:

    \(1*2^5 + 0*2^4 + 1*2^3 + 0 *2^2 + 1*2^1 + 1*2^0\)

    Base 2 numbers represent value (e.g., quantities, distances) the same as base 10 numbers. There is no such thing as a base 2 number verses a base 10 number. There is a value that can be represented base 2, base 10, or any other base. The value is always the same, it is only the representation that has changed. A number in base 2 can be translated to base 10 using this principal. Consider \(101011_2\), which is:

    \(1*2^5 + 0*2^4 + 1*2^3 + 0 *2^2 + 1*2^1 + 1*2^0 = 32 + 8 + 2 + 1 = 43_{10}\)

    In order to work with base 2 number, it is necessary to know the value of the powers of 2. The following table gives the powers of 2 for the first 16 numbers (to \(2^{15}\)). It is highly recommended that students memorize at least the first 11 values of this table (to \(2^{10}\)), as these will be used frequently.

    n

    2n

     

    n

    2n

     

    n

    2n

     

    n

    2n

    0

    1

     

    4

    16

     

    8

    256

     

    12

    4096

    1

    2

     

    5

    32

     

    9

    512

     

    13

    8192

    2

    4

     

    6

    64

     

    10

    1024

     

    14

    16348

    3

    8

     

    7

    126

     

    11

    2048

     

    15

    32768

    Table 2-2: Values of \(2^n\) for n = 0...15

    The first 11 (0..10) powers of 2 are the most important because when talking about numbers in base 2 these are the only ones used. This is because the values of \(2^n\) are named when n is a decimal number evenly dividable by 10. For example \(2^{10}\) is 1 Kilo, \(2^{20}\) is 1 Meg, etc. The names for these values of \(2^n\) are given in the following table.

    \(2^{10}\) Kilo   \(2^{30}\) Giga   \(2^{50}\) Penta
    \(2^{20}\) Mega   \(2^{40}\) Tera   \(2^{60}\) Exa

    Table 2-3: Names for values of 2n, n = 10, 20, 30, 40, 50, 60

    Using these names and the values of \(2^n\) from 0-9, it is possible to name the most commonly used binary numbers as illustrated below. To find the value of \(2^{16}\), we would write:

    \(2^{16} = 2^{10}*2^6= 1K * 64 = 64K\)

    Older programmers will recognize this as the limit to the segment size on older PC's which could only address 16 bits. Younger students will recognize the value of \(2^{32}\), which is:

    \(2^{32} = 2^{30} * 2^2 = 1G * 4 = 4G\)

    4G was the limit of memory available on more recent PC's with 32 bit addressing, though that limit has been moved with the advent of 64 bit computers.


    This page titled 2.1: Binary Numbers is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Charles W. Kann III via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.