BASE 10 TO BASE 2:
The places in a base 2 number are descending powers of 2.
128, 64, 32, 16, 8, 4, 2, 1
Let's say you wanted to represent 181 in binary (base 2).
Look at the powers of two in descending order. You need a 128, so put a 1 under it:
128, 64, 32, 16, 8, 4, 2, 1
.. 1
181 - 128 = 53
You have 53 left... you can't use 64, so put a 0 under it.
128, 64, 32, 16, 8, 4, 2, 1
.. 1....0
But you can use 32. Put a 1 under it.
128, 64, 32, 16, 8, 4, 2, 1
.. 1... 0 .. 1
Again subtract 53 - 32 = 21
You can use the 16, so put a 1 under it.
128, 64, 32, 16, 8, 4, 2, 1
.. 1... 0 .. 1 .. 1
Again subtract 21 - 16 = 5
You can't use the 8, so put a 0:
128, 64, 32, 16, 8, 4, 2, 1
.. 1... 0 .. 1 .. 1..0
You can use the 4, so put a 1 under it:
128, 64, 32, 16, 8, 4, 2, 1
.. 1... 0 .. 1 .. 1..0..1
Subtract 5 - 4 = 1
You can't use the 2, so put a 0 under it. Finally, use the 1 and put a 1 under it. Subtracting leaves 0, so you are done (if it doesn't you made a mistake).
128, 64, 32, 16, 8, 4, 2, 1
.. 1... 0 .. 1 .. 1..0..1..0..1
So 181 is equal to:
10110101 (base 2)
Note: Just like in base 10, you can ignore leading zeroes. So rather than having to write 00000101 to mean 5, you can just say 101 base 2. I always start with the first power of 2 that is less than or equal to my number and go from there...
BASE 2 TO BASE 10:
This is even easier. Just write the powers of 2 over each of the places in the binary number. Here it helps to start from the rightmost digit and go *left*, doubling each time.
So if you had 101011 you would write:
32 16 8 4 2 1
1 .. 0 .1 0 1 1
If the number has a 1 under it, add it. So this would be 32 + 8 + 2 + 1 = 43
101011 (base 2)
= 43 (base 10)
2007-12-04 11:53:39
·
answer #1
·
answered by Puzzling 7
·
0⤊
0⤋