Site hosted by Angelfire.com: Build your free website today!

BINARY NUMBER FUN

Converting to and from Binary Numbers


Let's begin with a binary number
Suppose it is:

   10011101  
               (it wouldn't have to be 10011101, 
                I just chose it because I thought it looked neat)

The first digit (starting from left) of the number is 1.
(1)0011101.  
This first digit is the same as saying (1*2^7) 
**Note:(^7 is the same as saying "to the 7th power")**

If we look at binary number                   10011101
                                              --------
then the power used for each digit -->        76543210
(directly under the binary number)
You once again see that for the first 
digit (1) you should use (1*2^7)

Got it so far?

So here comes the fun stuff
(1) 0  0  1  1  1  0  1        =(1*2^7)
 1 (0) 0  1  1  1  0  1        =(0*2^6)
 1  0 (0) 1  1  1  0  1        =(0*2^5)
 1  0  0 (1) 1  1  0  1        =(1*2^4)
 1  0  0  1 (1) 1  0  1        =(1*2^3)
 1  0  0  1  1 (1) 0  1        =(1*2^2)
 1  0  0  1  1  1 (0) 1        =(0*2^1)
 1  0  0  1  1  1  0 (1)       =(1*2^0)

Notice how I put the digit in the ( ) as the first number in the 
equation ( *2^#) and that # begins with 7 on the first row and then one is
subtracted every time until the last row is to 0?  Also notice that in the 
last row you are at the last ( ) digit?  
If you don't see what I am talking about try writing the above number chart 
on paper and looking for patterns.  It is all a game of patterns.

Well now let's take a look at the column on the right, and get out our
calculators.

(1*2^7)
(0*2^6)
(0*2^5)
(1*2^4)
(1*2^3)
(1*2^2)
(0*2^1)
(1*2^0)

If you type in (1*2^7) you should get the answer to be 128.
**Note: Remember that exponents (^#) has authority over multiplication so
you should be sure to put (2^#) in your calculator before you multiply it 
by 1 or 0**

So do this for each row and you should end up with these answers:

(1*2^7) = 128
(0*2^6) =   0
(0*2^5) =   0
(1*2^4) =  16
(1*2^3) =   8
(1*2^2) =   4
(0*2^1) =   0
(1*2^0) = + 1
          ---
          157

Now you add them all up and you should get the base-10 answer for 
binary number 10011101.
The answer is 157.  **YOU'RE FINISHED**  Wasn't that fun?
____

I know you don't want to hear anymore, but let's say you know the base-10
number, and what you are looking for is the binary number.  Can you figure
that one out?  Let's work it together :)

We'll use the above example to make it easier.
Let's say the base-10 number is 157.  
How do you find out what the binary number is?
Well, to do this let's remember that 11111111 =255.

If you can't remember that then work it out the long way.
(1) 1  1  1  1  1  1  1        =(1*2^7)    = 128
 1 (1) 1  1  1  1  1  1        =(1*2^6)    =  64
 1  1 (1) 1  1  1  1  1        =(1*2^5)    =  32
 1  1  1 (1) 1  1  1  1        =(1*2^4)    =  16
 1  1  1  1 (1) 1  1  1        =(1*2^3)    =   8
 1  1  1  1  1 (1) 1  1        =(1*2^2)    =   4
 1  1  1  1  1  1 (1) 1        =(1*2^1)    =   2
 1  1  1  1  1  1  1 (1)       =(1*2^0)    = + 1
                                             ---
                                             255  

Okay either way now you know 11111111 (binary)= 255(base-10)
 
We will use the column on the far right (rewritten below):
 =(1*2^7)    = 128
 =(1*2^6)    =  64
 =(1*2^5)    =  32
 =(1*2^4)    =  16
 =(1*2^3)    =   8
 =(1*2^2)    =   4
 =(1*2^1)    =   2
 =(1*2^0)    = + 1
               ---
               255  

Okay now we will look at our number, 157.
We will compare it to the first row in the                     157
far right column  (also re-written above).                   - 128   (1)
Think to yourself . o O ( can 128 go into 157? )             ----- 
-Yes-  So.. write down a 1, then subtract 128 from 157.         29
(as shown on right)                                          -   0   (0)
Write down your new answer  29.                              -----
Now think . o O ( can 64 go into 29? )                          29
-No-  So.. write a 0, then subtract 0 from 29.               -   0   (0)
Write down your new (same) answer 29.                        -----
Now think . o O ( can 32 go into 29? )                          29
-No-  So.. write a 0, then subtract 0 from 29 again.         -  16   (1)
Write down your new (same) answer 29.                        -----
Now think . o O ( can 16 go into 29? )                          13
-Yes-  So.. write down a 1, then subtract 16 from 29.        -   8   (1)
Write down your new answer  13.                              -----
Now think . o O ( can 8 go into 13? )                            5
-Yes-  So.. write down a 1, then subtract 8 from 13.         -   4   (1)
Write down your new answer  5.                               -----
Now think . o O ( can 4 go into 5? )                             1
-Yes-  So.. write down a 1, then subtract 4 from 5.          -   0   (0)
Write down your new answer  1.                               -----
Now think . o O ( can 2 go into 1? )                             1
-No-  So.. write a 0, then subtract 0 from 1.                -   1   (1)
Write down your new (same) answer  1.                        -----
Now think . o O ( can 1 go into 1? )                             0
-Yes-  So.. write down a 1, then subtract 1 from 1.

You are left with 0.  You are done.  Now look along the side of your long
subtraction equation in the ( ).  Write down those numbers in order and you
have  your binary number.  Therefore, in this equation we have the binary
number:
10011101.

Isn't that great?  If at the end of your long subtraction equation you are
not left with a 0, you need to redo the long subtraction equation paying 
close attention.  
1.  **Make sure you are subtracting in order and using the correct 
    numbers: 128,64,32,16,8,4,2,1**  [these numbers are simply (1*2^7),
    (1*2^6), etc.]
2.  **Double check to make sure you subtracted correctly (ie.  29-16 does
    not equal 15)** 
3.  **and finally make sure the base-10 number is not more than 255**  
    [If it is, you can not make an 8-digit binary number out of it; instead
    try a higher digit binary number, and make sure to the formulas 
    correspond to that new digit]
That's all, I think.  Hope this helped.  Print it up, study it, and practice it. 
Or just look at it once and throw it away.  I don't care :)

--Shannon--
@}>--,--`---