------------------------------------------------ BBB A SSSS EEEE MMMMM A TTTTT H H B B A A S E M M M A A T H H BBB A A SSSS EEEE M M M A A T HHHHH B B AAAAA S E M M M AAAAA T H H BBB A A SSSS EEEE M M A A T H H ------------------------------------------------ NOTE: ANYTHING to the power of 0 is 1. Let's look at the decimal system again (Not again! Haven't we had enough of confusions already?[:-(]).What does 4285 mean?(Am I in a kintergarden school or what?)Well, it means this:- 4 x 10^3 + 2 x 10^2 + 8 x 10^1 + 5 x 10^0 As you might have guessed, 10 comes from the base of the numerical system used. Now what does 1001012 mean? Just as complicated as above, it means:- 1 x 2^5 + 0 x 2^4 + 0 x 2^3 + 1 x 2^2 + 0 x 2^1 + 1 x 2^0 = 32 + 4 + 1 = 37 There you are! Now you know how to convert any binary number to its decimal equivalent. (Believe me, this is the standard method.) Now what's left? Converting a decimal number to binary. For instance, you want to convert 4285 to binary. Divide 4285 by 2. Note the quotient and remainder below 4285 like this:- 2|4285 2142 - 1 Do the same with the quotient. And then again ... till it is 0. Thus, continuing with our previous operation, by the time we reach 0, the result should look somthing like this:- 2|4285 2|2142 - 1 2|1071 - 0 2| 535 - 1 2| 267 - 1 2| 133 - 1 2| 66 - 1 2| 33 - 0 2| 16 - 1 2| 8 - 0 2| 4 - 0 2| 2 - 0 2| 1 - 0 0 - 1 You now have quite a handful of remainders, haven't you? Now arrange the remainders from bottom to top. The number is 1000010111101. That's it. 428510=1000010111101^2. So now you can convert a binary number to and from a decimal number, can't you? But you will have to practice this thing a lot if you want to become a professional assembler programmer. I said it is very easy to do conversion. Suppose you need to convert 10001011011012 to something hexadecimal. At first, separate the number into pieces of four digits from the right-hand side. Therefore, 1000101101101 becomes:- 0001 0001 0110 1101 (you can add as many 0s as you wish on the left-hand side) Now convert each part into its haxadecimal equivalent. Thus you get:- 0001 0001 0110 1101 | 1 || 1 || 6 || D | 1000101101101^2 = 116D^16 Similarly, if you want a hexadecimal number, say B2D16, to be converted to binary, Write down the four digit binary equivalent of each hexadecimal digit. So B2D16 becomes:- | B || 2 || D | 1011 0010 1101 101100101101^2. To convert hexadecimal to decimal, do the same thing you did while converting binary to decimal. Suppose, you want to convert DAF16. So, this can be written as: D x 10^2 + A x 10^1 + F x 10^0 Now don't you confuse yourself! The 10s shown above really mean 16. That's because the 10s are 1016, which means 16 in decimal. So if you want to convert DAF to decimal, simply replace the 10s with 16s and all hexadecimal digits greater than 9 (ie. A,B,C,D,E and F) by their decimal equivalents. Thus the above becomes:- 13 x 16^2 + 10 x 16^1 + 15 x 16^0 = 13 x 256 + 10 x 16 + 15 x 1 = 3328 + 160 + 15 = 3503 Therefore, DAF^16 = 3503^10. So, you now know a lot about base-n systems don't you? Well you still have more than a lot to learn. How do you convert decimal number, say 723, to a hexadecimal number? Remember how to do a decimal-to-binary convertion? Recall what you learnt then (You didn't expect to get rid of that strange division so soon, did you?). Repeated division, right? Now all you need to do is replace the 2s by 16. And one more thing! If the remainder is 10 or more, replace it by the hexadecimal equivalent. So 723 is processed like this:- 16|723 16| 45 - 3 16| 2 - D (If you expected 13, sorry) 0 - 2 So, 72310 = 2D316 Phew! Hope you got that much. Now you should be able to understand what is actually meant by counting in bases other than 10.