Wednesday, February 21, 2007

Binary Conversions

First, to convert the decimal number 529 to decimal you continually divide the number by 2, and if there is a remainder after each division it represents a "1". The numbers which divide evenly will thus represent a "0" in the binary representation. This is better explained just by showing it, so here is the conversion for 529. (R=remainder). Notice how the right side forms the binary code which is read from bottom up.
529
529/2 = 264 R 1
264/2 = 132 R 0
132/2 = 66 R 0
66/2 = 33 R 0
33/2 = 16 R 1
16/2 = 8 R 0
8/2 = 4 R 0
4/2 = 2 R 0
2/2 = 1 R 0
1/2 = 0 R 1

Thus, the binary code for 529 is 1000010001.


To convert from decimal to binary is a bit more complicated in my opinion, but not very difficult at all once the concept is understood. The binary 110010101 is represented in decimal by multiplying (from right to left) the binary number times 2 to the power of the n-1. For example, there are 9 numbers in this sequence. The numbers are then added together to get the final decimal number. So the first number (the "1" all the way to the right) is multiplied by 2^0. (n=1, so n-1=0). Likewise, the last number "1" (all the way to the left) is multiplied by 2^8 (n=9, so n-1=8), or 258. Below is the long-hand math done for the binary of 110010101.

1*2^0 = 1
0*2^1 = 0
1*2^2 = 4
0*2^3 = 0
1*2^4 = 16
0*2^5 = 0
0*2^6 = 0
1*2^7 = 128
1*2^8 = 258

So, the decimal of 110010101 is (1+0+4+0+16+0+0+128+258) = 405



The difference between a positional and non-positional number system is relatively simple. Positional numbers are numbers which contain a base, normally 10 in the English number system. Which means that there is a specific set of symbols (in our case, 0-9) which, depending on the placement, makes the value greater or lower. For example, we have "places" for each number, "5" alone represents a much lower number than "500" simply because the 5 is in the "hundreds" place in this case.
Non-positional numbers are complex in that you have to understand what each symbol represents in relation to the numbers next to it. There is not a constant multiplier and the position does give the value an increase or decrease. The Roman Numeral System works on this concept. For example XIII is equal to 13. The position the X is in does not give it a specific value other than what it represents which is a 10. The "I's" following only represent 1s.

No comments: