Go Back   Gaming Gutter


» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Black Friday
11-26-2008 11:14 AM
Last post by Angels_Halo
Today 03:52 AM
30 Replies, 204 Views
Go to first new post Do you think smoking is...
08-16-2008 07:09 PM
Last post by Angels_Halo
Today 03:49 AM
261 Replies, 2,803 Views
Go to first new post What was your first job?
09-21-2008 08:23 PM
by Zombii
Last post by Angels_Halo
Today 03:46 AM
60 Replies, 510 Views
Go to first new post Whats your favorite song?
08-06-2008 09:53 PM
Last post by Angels_Halo
Today 03:44 AM
59 Replies, 430 Views
Go to first new post Storing files externally
11-11-2008 05:39 PM
by Axed
Last post by Mrs. Morris
Today 02:46 AM
8 Replies, 64 Views
View Single Post

 Binary to Decimal and back.
Old 07-01-2008, 07:47 AM   #1 (permalink)
FireWrath
Banned

Undisclosed FireWrath is offline
 
Join Date: Oct 2007
Posts: 3,209
GPoints: 70
iTrader: 1 / 100%
FireWrath Total CelebrityFireWrath Total CelebrityFireWrath Total CelebrityFireWrath Total CelebrityFireWrath Total CelebrityFireWrath Total Celebrity
Rep Power: 0
Binary to Decimal and back.

I got the idea from Matt's guide where he explained the binary to ASCII deal on here. This is a simlar concept, but going from a base-two number (binary) to a base ten number (decimal).

Normally when you count you start with 0 and work your way up until you hit 9, then it starts over again, such as 1 then 2, 3, 4 up until you hit 9, then it goes back down to 10, 11 13. The same is done with binary, only it goes from 0 to one, then it starts over again.

Let's go with counting, to make it easy, and just to make it simply to follow, we'll go with binary:decimal.
0:0
1:1
10:2
11:3
100:4
101:5
110:6
111:7
1000:8
1001:9
1010:10
The concept is fairly easy, especially in counting, but how do you go from decimal to binary? Well this is where you have to put your basic math skills to a use. Easiest thing is to draw a table. The table should start at 1, then keep multiplying by 2 until the last number is equal to, greater than the number in decimal, and should go from left to right. Here's an example for 10:
16 8 4 2 1
Now that you have a table, you start with the left number (the biggest one). If that number is bigger than the decimal, stick a 0 in there and move on, otherwise place a 1. Subtract that number from the original, and keep going until the number reaches 0. Let's go back to the table:
16 8 4 2 1
0
Original number: 10. Ignore it. Move on.
16 8 4 2 1
0 1
Original number: 10. Subtract 8. Move on.
16 8 4 2 1
0 1 0
New number: 2. Ignore it. Move on.
16 8 4 2 1
0 1 0 1
New number: 0. Fill the rest with 0's. You're done.
16 8 4 2 1
0 1 0 1 0
Any zeros in the begining you can ignore, so the outcome is 1010. Looking back at when we counted from 0 to 10 to double check, that is in fact correct.

Now to go from binary to decimal you do a fairly simiar thing. Let's take a longer number like 1011001. Now draw the same chart again.
64 32 16 8 4 2 1
1 0 1 1 0 0 1
All you do is add everyone you see a 1, and the total is that binary number converted to decimal. So let's go step-by-step again:
64+16=80
80+8=88
88+1=89
And you're done.

Here's a picture of what a table would look like because making the correct spacing without the ability to have the extra spaces needed is hard. I know it's not straight, deal with it. http://img360.imageshack.us/img360/2729/binbq6.png
  Reply With Quote
 
Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 03:52 AM.


vBulletin skin developed by: eXtremepixels
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.13221788 seconds (100.00% PHP - 0% MySQL) with 18 queries