| |
Steps:
- Get the last digit of the hex number, call this digit the currentDigit.
- Make a variable, let's call it power. Set the
value to 0.
- Multiply the current digit with (2^power),
store the result.
- Increment power by 1.
- Set the the currentDigit to the previous digit of the
hex number.
- Repeat step 3 until all digits have been multiplied.
- Sum the result of step 3 to get the answer number.
Example
Convert BINARY 11101 to DECIMAL
| NOTES |
MULTIPLICATION |
RESULT |
| start from the last digit, which is 1,
multiply that digit with 2^0, note that the power of 0 of
any number is always 1
11101 (current digit is in bold)
|
1*(2^0) |
1 |
| process the previous digit, which is 0,
multiply that digit with the increasing power of 2
11101 (current digit is in bold)
|
0*(2^1) |
0 |
| process the previous digit, which is 1, note
that 2^2 means 2*2
11101 (current digit is in bold)
|
1*(2^2) |
4 |
| process the previous digit, which is 1, note
that 2^3 means 2*2*2
11101 (current digit is in bold)
|
1*(2^3) |
8 |
| process the previous digit, which is 1, note
that 2^4 means 2*2*2*2
11101 (current digit is in bold)
|
1*(2^4) |
16 |
| here, we stop because there's no more digit
to process |
|
|
| this number comes from the sum
of the RESULTS |
ANSWER |
29 |
Basically, this is the same as saying:
1*(2^4) + 1*(2^3) + 1*(2^2) + 0*(2^1) + 1*(2^0)
or
1*(16) + 1*(8) + 1*(4) + 0*(2) + 1*(1)
The reason it's easier to start backward is because:
- Counting the number of digits takes extra time, and you
might count wrongly.
- If you don't remember what a particular power-of-2 value, it's easy to calculate it from the previous
value. For instance, if you don't remember what the
value of 2*2*2 is, then just double the value of 2*2 (which
you already have - if you had started backward).
Another Example
Convert BINARY 1010 to DECIMAL
| MULTIPLICATION |
RESULT |
| 0*(2^0) |
0 |
| 1*(2^1) |
2 |
| 0*(2^2) |
0 |
| 1*(2^3) |
8 |
| |
|
| ANSWER |
10 |
Is constructing a table like above required? No, it just
depends on your preference. Some people are visual, and the
table might help. Without a table, it's also easy. If you want to be a speed counter, just remember that the value
of the multiplier is always the double of the previous
one.
1, 2, 4, 8, 16, 32, 64, 128, 256, 512, ...
| POWER OF 2s |
RESULT |
| 2^0 |
1 |
| 2^1 = 2 |
2 |
| 2^2 = 2*2 |
4 |
| 2^3 = 2*2*2 |
8 |
| 2^4 = 2*2*2*2 |
16 |
Example
Convert BINARY 1010001 to DECIMAL.
Again, I'm starting backward here:
(1*1) + (0*2) + (0*4) + (0*8) + (1*16) + (0*32) + (1*64) =
1 + 0 + 0 + 0 + 16 + 0 + 64 = 81
|
|