Working with Binary Numbers


Computers are, at the most fundamental level, simply a collection of electrical switches. Numbers and characters are represented by the positions of these switches. Because a switch has only two positions, on or off, it uses a binary, or base 2, numbering system. (The root bi means two.) A base 2 system has only two digits: 0 and 1.

Computers usually group these digits into eight place values, known as a byte or an octet. The eight place values are


    27 26 25 24 23 22 21 20

The place values are calculated as follows:


    20 = 1
    21 = 1 x 2 = 2
    22 = 2 x 2 = 4
    23 = 4 x 2 = 8
    24 = 8 x 2 = 16
    25 = 16 x 2 = 32
    26 = 32 x 2 = 64
    27 = 64 x 2 = 128

So, the place values of a binary octet are


    128  64  32  16  8  4  2  1

Thus, the binary octet 10010111 can be read as follows:


    1 x 128 = 128
    0 x 64 = 0
    0 x 32 = 0
    1 x 16 = 16
    0 x 8 = 0
    1 x 4 = 4
    1 x 2 = 2
    1 x 1 = 1
    or 128 + 16 + 4 + 2 + 1 = 151

Working in binary is easy because for every place value there is either one quantity of that value or none of that value. For another example, 11101001 = 128 + 64 + 32 + 8 + 1 = 233.

Where converting binary to decimal is a matter of adding the place values, converting from decimal to binary is a matter of subtracting place values. To convert the decimal number 178 to binary, for instance, begin by subtracting the highest base 2 place value possible from the number:

  1. 178 is greater than 128, so we know there is a 1 at that place value: 178 128 = 50.

  2. 50 is less than 64, so there is a 0 at that place value.

  3. 50 is greater than 32, so there is a 1 at that place value: 50 32 = 18.

  4. 18 is greater than 16, so there is a 1 at that place value: 18 16 = 2.

  5. 2 is less than 8, so there is a 0 at that place value.

  6. 2 is less than 4, so there is a 0 at that place value.

  7. 2 is equal to 2, so there is a 1 at that place value: 2 2 = 0.

  8. 0 is less than 1, so there is a 0 at that place value.

Putting the results of all these steps together, 178 is 10110010 in binary.

Another example might be helpful. Given 110,

  1. 110 is less than 128, so there is a 0 at that place value.

  2. 110 is greater than 64, so there is a 1 at that place value: 110 64 = 46.

  3. 46 is greater than 32, so there is a 1 at that place value: 46 32 = 14.

  4. 14 is less than 16, so there is a 0 at that place value.

  5. 14 is greater than 8, so there is a 1 at that place value: 14 8 = 6.

  6. 6 is greater than 4, so there is a 1 at that place value: 6 4 = 2.

  7. There is a 1 at the 2 place value: 2 2 = 0.

  8. 0 is less than 1, so there is a 0 at that place value.

Therefore, 110 is 01101110 in binary.




CCIE Professional Development Routing TCP/IP (Vol. 12005)
Routing TCP/IP, Volume 1 (2nd Edition)
ISBN: 1587052024
EAN: 2147483647
Year: 2005
Pages: 233

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net