CPSC 110,  Spring 2002   

with Brent M. Dingle

 

Knowledge Tidbit:

 

The computer stores “everything” as zeros or ones.

Why?

                The computer stores “everything” in its memory.

The computer’s memory is composed of bytes (one kilobyte (kb or just k) is 1024 bytes)

Every byte contains 8 bits.

Every bit contains a zero or a one.

 

This means numbers must be stored in BINARY form (i.e. base 2).

Recall our “normal” numbering system is base 10.

In our normal numbering system the rightmost digit represents how many ONEs there are.

The second rightmost digit represents how many TENs there are.

The third rightmost digit represents how many HUNDREDs there are,

The fourth rightmost digit represents how many THOUSANDs there are and so on.

Notice that 100 = 1, 101 = 10, 102 = 100, 103 = 1000… pretty neat isn’t it?

For example:

1234        =  ( 1 * 103 )  +  ( 2 * 102 ) +  ( 3 * 101 ) + ( 4 * 100 )

                                =  ( 1 * 1000 ) +  ( 2 * 100 )  +  ( 3 * 10 )  +   ( 4 * 1 )

                =  1000 +  200  + 30 +  4

                                = 1234

 

Notice we use TEN symbols for digits ŕ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

 

 

Binary (base 2) numbering works in the same fashion.

The rightmost digit represents how many ONEs there are.

The second rightmost digit represents how many TWOs there are.

The third rightmost digit represents how many FOURs there are.

The fourth rightmost digit represents how many EIGHTs there are, and so on.

For example:

0001        =   ( 0 * 23 )  +  ( 0 * 22 )  +  ( 0 * 21 )  + ( 1 * 20  )   =  0 + 0 +  0 + 1 =  1

0010        =   ( 0 * 23 )  +  ( 0 * 22 )  +  ( 1 * 21 )  + ( 0 * 20  )   =  0 + 0 +  2 + 0 =  2

0011        =   ( 0 * 23 )  +  ( 0 * 22 )  +  ( 1 * 21 )  + ( 1 * 20  )   =  0 + 0 +  2 + 1 =  3

0100        =   ( 0 * 23 )  +  ( 1 * 22 )  +  ( 0 * 21 )  + ( 0 * 20  )   =  0 + 4 +  0 + 0 =  4

0101        =   ( 0 * 23 )  +  ( 1 * 22 )  +  ( 0 * 21 )  + ( 1 * 20  )   =  0 + 4 +  0 + 1 =  5

   :

1000        =   ( 1 * 23 )  +  ( 0 * 22 )  +  ( 0 * 21 )  + ( 0 * 20  )   =  8 + 0 +  0 + 0 =  8

   :

1111        =   ( 1 * 23 )  +  ( 1 * 22 )  +  ( 1 * 21 )  + ( 1 * 20  )   =  8 + 4 +  2 + 1 =  15

 

Notice we use only TWO symbols for the digits  ŕ 0, 1