CIS3355:
Business Data Structures |
An Alternative Method for converting from Binary to Decimal Some of you may have learned an alternative method for converting from binary to decimal. Whatever method works for you is fine with me. Let's take the binary number: 101 (which we know is 5 in base 10). The way that we went over it in class was:
→ 1 * 22 + 0 * 21 + 1 * 20 = 22 + 20 = 4 + 1 = 5
Instead of using simply the exponent value, we could have entered in the Value of our exponent (i.e., the value of 2n, where n is the exponent value):
Now all we have to do is add the exponent values whenever the bit is 1: 4 + 1 = 5 Let's take another example: convert 110110012 to decimal. Method 1:
= 27 + 26 + 24 + 23 + 20 = 128 + 64 + 16 + 8 + 1 = 217 Method 2:
= 128 + 64 + 16 + 8 + 1 = 217 It's really the same, but we are (sort-of) eliminating one step. This page was last updated on 02/11/04
|