Jan's Computer
        Basics
Intro
1. Computer
    Types
2. Applications
3. Input
4. Processing
5. Output
6. Storage
7. Computer to
    Computer
8. System
    Software
9. Programming
10. What You
      See
11. Hands On!
12. On Your
      Own
Glossary
Appendix
 
Home
Lessons
Archives
About
 
Jan's Illustrated Computer Literacy 101 Logo:Jegsworks Jan's Illustrated Computer Literacy 101


Home > Jan's CompLit 101 > Computer Basics > Appendix : Base Arithmetic

Jan's Computer Basics:

Appendix: Base Arithmetic

Counting on fingersHuman beings have generally settled on ten as the number to count with. No doubt it has something to do with the number of counting tools available (fingers, that is!).

There is nothing magic about ten, however, that makes it the best choice (except for those who count with those handy, dandy fingers). Some cultures have indeed used other numbers to count with. Babylon apparently used sixty, a sexagesimal numbering system, which has some calculating advantages since it divides evenly by two, three, four, five, six, ten, twelve, fifteen, twenty, and thirty.

The simplest way of writing numbers is to make one mark for each thing counted. counting with marksNote that our usual way of marking four vertical strokes and then a crossing stroke forms groups of five. Hmm. Five fingers on one hand. Any connection, do you think??

Once the number of cattle you own exceeds the number of fingers you have, it becomes clear that you need a short way of writing large numbers. Our modern system uses the position of a number symbol to indicate its real value. So our cattle ranchers don't have to scratch out several feet of little marks to write down the number of cows they have.

Instead they write numbers like 4567. What that really means is 4 thousands plus 5 hundreds plus 6 tens plus 7 ones. So far so good. How does that relate to using other bases? Look at how this works.

Base 10
a thousand = 10 x 10 x 10= 103
a hundred = 10 x 10= 102
ten = 10= 101
one = 1= 100

This way of writing 10 x 10 x 10 as 103 names 3 as the power of 10. So we could write our number as powers of 10 this way:

(4 x 103)+ (5 x 102)+ (6 x 101)+ (7 x 100 )

Each digit is multiplied by a power of 10 to get the complete number.

We can use this same kind of notation with any base. We just need to know what the base is and what the symbols are for the numbers smaller than the base.


Computers love Base 2

Computers don't have ten fingers to count with. All they have is on and off. Everything inside a computer must be represented with some combination of on and off. We humans use the digits 1 for on and 0 for off. We call this base 2 since there are only 2 symbols used.

A sequence of on off off on off on on off on is written for the benefit of humans as 100101101. This is only a little bit better but it takes less energy to write down. Such base 2 numbers are called binary numbers.

Now the number 100101101 in base 2 uses the same symbols as 100,101,101 in base ten. But the base 10 number is equal to one hundred million one hundred and one thousand one hundred and one. This is a much larger number than the base 2 number.

The 1s and 0s must be multiplied by powers of 2 to see how many cows this number represents.

100101101
in base 2
= in base 10
1 x 28 = 1 x 256 256
0 x 27 = 0 x 128 0
0 x 26 = 0 x 64 0
1 x 25 = 1 x 32 32
0 x 24 = 0 x 16 0
1 x 23 = 1 x 8 8
1 x 22 = 1 x 4 4
0 x 21 = 0 x 2 0
1 x 20 = 1 x 1 1
Total = 301
in base 10

The rules for adding base 2 numbers are simple.

0 + 0 = 0
0 + 1 = 1
1 + 1 = 10
1 + 1 + 1= 11

For example, adding the two numbers below:

(don't forget to carry a one over if the column is 1 + 1 = 10)

    10101101
  +  1011110
   100001011


Base 16 is for people (Really!)

Because people have a really hard time keeping straight numbers like those above, computer numbers are often written in yet another base - base 16. Such numbers are called hexadecimal. Hexadecimal numbers look really odd because they have more symbols than we are used to. Letters are used for the numbers from ten through fifteen: A = 10; B = 11; C = 12; D = 13; E = 14; F = 15. They can be either upper case or lower case.

The numbers we added above if written as base 16 numbers look like:

  3F2
+ B37
  F29

To interpret such numbers as base 10 numbers, ( for those of us who just can't quit counting on our fingers!) you need to know the powers of 16.

163 = 4096
162 = 256
161 = 16
160 = 1

So the number F29 in base 16 is equal to:

(F x 162)+ (2 x 161)+ (9 x 160 ) =

15 x 256 = 3840
2 x 16   =   32
9 x 1    =    9
           3881 in base 10

This is certainly not all that easy to do. Few people can multiply 15 by powers of 16 easily. But the really advantage for base 16 is in how easy it is to change from base 2 to base 16 and back.

Every hexadecimal digit is broken down into a 4 digit binary number. These digits are just written down in the same order as the hexadecimal number and you've got the equivalent binary (base 2) number.

For our number F29 :

F is equal to 15 which is 8 + 4 + 2 + 1. (These are the powers of 2).
That means that F = (1 x 23) + (1 x 22) + (1 x 21) + (1 x 20).

(We'll use little numbers at the bottom, called subscripts, to show what base the number is using)

So F16 = 11112

Since 216 is (1 x 21), then 216 = 00102

Since 916 is (1 x 23 ) + (1 x 20), then 916 = 10012

Putting this together makes F2916 = 1111001010012.

Once you learned how to write the numbers 0 to 15 in base 2, you could whip back and forth between base 2 and base 16 rapidly. Some folks who work with computers have to do just that.

Thank goodness most of us don't have to do this all the time! One number system is enough to deal with!! But now you know a little about the numbers computers think with and how people write them down.

(Use your Back button to return to the page that sent you here or use the menu or crumbs to pick another page to view.)