How is this done?
- Write down a decimal point.
- Start with a decimal value between 0 and 1.
- Multiply by 2.
- If your result is less than 1, write down a 0.
- If your result is greater than 1, write down a 1 and subtract 1.
- Return to step 2.
say what? sounds like a 0 either way, per your system. no, i was referring to whole numbers (base ten system) like 3, or 77, or 943.
Ahh it’s been ages since I’ve had to do this, but here’s the basic procedure. It involves long division and remainders.
Essentially you divide the number by 2, write the result and note the remainder. Perform the same procedure on the result and note the remainder. Do this until you can’t do it no more!
Let’s say you want to convert 100 in decimal to binary.
100/2 = 50 rem 0
50/2 = 25 rem 0
25/2 = 12 rem 1
12/2 = 6 rem 0
6/2 = 3 rem 0
3/2 = 1 rem 1
1/2 = 0 rem 1.
At this point, write the remainders in reverse order, and you have your binary number, in this case 1100100.
Provided you have sufficient patience you can do this with any whole number.
Hope this helps!
Max.
such lucidity, thank you. a tad cumbersome, though. how to convert from binary to decimal, now?
Ah, maybe I can help. Start with 0. Multiply by 2 and add the next digit! Repeat! As an example, let’s take 1001101:
0 × 2 + 1 = 1
1 × 2 + 0 = 2
2 × 2 + 0 = 4
4 × 2 + 1 = 9
9 × 2 + 1 = 19
19 × 2 + 0 = 38
38 × 2 + 1 = 77
Hope this makes up for my earlier misunderstanding. Good luck!
If you have Windows, you can use the calculator. Set the View to “Scientific”, type in the decimal number and then click the “Bin” button. Vice versa to convert from binary to decimal.
I’ve always used a slightly different approach. Let’s say you have a number of 189. Using the table below (okay just imagine those numbers are in a table)Assuming that we are only working with an eight digit binary number, the binary number 11111111 = 255 in decimal.Take your decimal number and subtract from it the highest or equal number on the table. So for a number of 189 it would go like this:
128 64 32 16 8 4 2 1
189-128=61
61-32=29
29-16=13
13-8=5
5-4=1
1-1=0
So we look at our chart.
Did we use the 128? Yes then that gets a 1
Did we use the 64? No, so that gets a 0
Did we use the 32? yes okay it’s a 1
Did we use the 16? it’s a 1
Did we use the 8?another 1
How about the 4? Okay add another 1
How about the 2? NO? it’s a 0 then
We also used the 1 because it was equal to the 1 ,so it’s 1
Go down the list. Our binary number is 10111101
Confusing? Maybe, but it works for me.
That’s a good method too, Qwisp. I use it when I can do the math in my head. However, one reason that Maxxxie’s method is so good is that it’s very easy to convert to bases other than 2. For instance, I want to put 12345[sub]dec[/sub] into base 7:
12345 / 7 = 1763 rem 4
1763 / 7 = 251 rem 6
251 / 7 = 35 rem 6
35 / 7 = 5 rem 0
5 / 7 = 0 rem 5
So 12345[sub]dec[/sub] = 50664[sub]base 7[/sub]. Of course, in real life, the only numerical bases you run into are 2, 10, and 16 (and 8 apparently, though I never have). But it’s still neat to know.
WOW! That’s the neatest way I’ve ever seen of converting bases. I’ve always done it by writing a chart with (say we’re dealing in octal):
8^3, 8^2,8^1,8^0
or
512, 64, 8, 1
in each column. Then, say our number is 100, I’d get
0 in the 512 column (since 100 is less than 512)
1 in the 64 column (since a 2 would give 128, higher than our number)
4 in the 8 column (since 84=32 plus the 64 we have makes 96, the closest we can get to 100 without going over)
4 in the 1 column (41 = 4 + 94 = 100)
so, 100 is 144 in octal.
So basically, it works just like Qwisp’s method in different bases. It’s like playing “Price Is Right.” In each column, you have to find a number that gets you closest to the target value without going over. Of course, I can explain it more mathemetically, say like:
512, 64, 8, 1
Since 100 is less than 512, the 512s place gets a zero.
100/64 equals 1.5623, so the 64s place gets a 1
So we’ve covered 64 units of our 100. 100-64=36
36/8 = 4.something. the 8s place gets a 4
We have 4 units still to cover
4/1=4, so the 1s place gets a 4
144
(18^2)+(48^1)+(4*8^0)
No matter how I write it out, it seems hopelessly complex, but I swear it’s easy. But I love Maxxxie’s method. Cool.