+- Computer Tech ( http://computertech.createmybb3.com)+-- Forum: Programming ( /forumdisplay.php?fid=6)+--- Forum: Other Programming Languages ( /forumdisplay.php?fid=11)+--- Thread: [Tutorial] Numbering Systems and Conversions ( /showthread.php?tid=117) |

[Tutorial] Numbering Systems and Conversions - Hidden Dragon - 01-16-2011 03:21 AM
Though this applies to different languages, I think it is most important in assembly language. We'll take a look at the decimal numbering system, the binary numbering system, and the hexadecimal numbering system. Decimal Numbering System
The decimal numbering system is what we use in everyday life. It is operated on base 10. When you think of the number 429 it can be represented different ways.Code: `429` Binary Numbering System
The binary numbering system is operated on base 2. When you take 429 it can be represented asCode: `110101101` Hexadecimal Numbering System
The hexadecimal numbering system is operated on base 16. Some people shorten hexadecimal to hex but that is not the same thing. Hex would denote a base 6 instead of base 16. Since we can only use the numbers 0-9, we also need other characters for 10-15. Instead of making up symbols we use the letters A-F. A=10 B=11...F=15.Again using our 429 example, we have Code: `1AD` Now we're going to talk about conversion between all of these. Binary to hexadecimal and hexadecimal to binary is the easiest conversion we can do so we're going to start with that. Binary to Hexadecimal
Say we have the number 11010. First we have to make our binary number divisible by four. Since we have five numbers we need to fill 3 with 0s. Now we've got 00011010. We have to break that up into four binary digits. 0001 1010 Now that we have that, we can convert to hexadecimal. If you know this conversion chart, it's very easy to convert. [spoiler]Binary Hexadecimal 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F[/spoiler] That conversion chart would be good to memorize. Using the chart we have Code: `0001 1010` Hexadecimal to Decimal
Lets use another number for our hexadecimal to decimal numbering. For this, we'll use the number 42B2.This isn't a very hard conversion to do either although none of these really are that difficult. Code: `42B2 gives us` Now lets convert our number that we got from binary to hexadecimal. Code: `1A` Binary to Decimal
We're going to use our previous example of 11010 for this problem. This is base 2 so it's also pretty easy to do.Code: `11010` It's pretty easy to reverse all of these formulas and get the opposite starting with the opposite. Hope you've learned something with this. If you have any questions, feel free to post them. Just don't ask about hex to decimal because it's the hardest Really, feel free to ask about anything. Have fun with your conversions! RE: [Tutorial] Numbering Systems and Conversions - Ironside - 01-16-2011 11:21 AM
Already knew this myself, but will definitely come useful to people new to this. |