Welcome! Log In Create A New Profile

Advanced

[SOLVED] Having a bit of trouble learning hexadecimal...

Posted by Sonicdude41 
[SOLVED] Having a bit of trouble learning hexadecimal...
February 21, 2010 02:59AM
So I recently got into binary code. So far I've been able to teach myself to find the value of a binary number.

One example: 01101010 is 106 in base 10 (correct me if I'm wrong).

I would think that if I can understand this, I can understand hex. But my mind seems to be having a problem wrapping around it (probably due to the six arbitrary characters: A, B, C, D, E, F).

Would someone be willing to lead me in the right direction? Stuff like this is really interesting to me, and I really would like to be able to master this. After all, knowledge is power. =)



Edited 1 time(s). Last edit at 02/21/2010 07:43PM by Sonicdude41.
Re: Having a bit of trouble learning hexadecimal...
February 21, 2010 03:20AM
this site is really helpful [mirror.href.com]
Re: Having a bit of trouble learning hexadecimal...
February 21, 2010 05:31AM
To understand binary or hex (or even quaternary) you have to understand how bases work.

The first step to understanding bases is figure out what base a number is part of. To do that, count how many numbers are in that number's number system.

*Binary only has 2 characters in it: 0 and 1. Thus, binary is referred to as being a base 2 number system.
*Our Decimal system has 10 characters in it: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Thus, our decimal system is referred to as being in base 10.
*Hexadecimal has 16 characters in it: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Thus, hexadecimal is a base 16 number system.

If a number is not written in base 10 (Decimal), it should have a subscript saying what base it is in. Example: Binary should be written like this: 1010101011101002

Do you remember how they taught you to add in grammar (elementary for Americans like me) school? You used columns like the ones, tens, hundreds, thousands, etc. column. Like when you had a problem like the one below:
19
+3
-----
22

You were taught to add a one to the tens column after you exceeded the value of nine in the ones column. (You were also taught to add a one to the hundreds column after you exceeded a value of 9 in the tens column and so on and so forth). If you had for example, a 2 in the the ten;s column wit would have a value of 10 because 10*2=20. Likewise, that 9 in the example above has a value of 9 because 9*1=9. I guess you could say Number*ColumnValue=TrueValue. Most importantly, what I'm trying to do here is jog your memory of that 'columns system'.

Now consider this: How do you think the value of each column was determined?

The value of each column was determined by taking the base number (10 in our decimal system) and giving it an exponent of the column placement. Remember you move from right to left when doing this. Thus, the first column was the ones column because 10^0 is 1. The second column the tens column because 10^1 is 10. The third column the hundreds column because 10^2 is 100.

Now this column system I've finished fully describing applies to any base, just change the base number. So for binary (base 2), the first column is the one's column because 2^0 is 1. The second column is the two's column because 2^1 is 2. The third column is the four's column because 2^2 is 4. The fourth column is the eight's column because 2^3 is 8.

11112 (binary) is equivalent to 15 in decimal because (1*1)+(1*2)+(1*4)+(1*8)=15.

For hexadecimal (base 16) this application works the same way. The only thing that throws some people off about hexadecimal (as you mentioned) is the letters. Here's the hexadecimal to decimal conversion for them:
Hex -> Decimal
A         10
B         11
C         12
D         13
E         14
F         15
Before I move on with my lesson I want to point something out quick that's in huge relevance to digital circuitry and programming. The max value for one character of hex is 15. Thus, any one character in hex is equivalent to 4 characters in binary. If you don't fully understand why, take a look at that 1111 in base 2 equals 15 in base 10 example above again. Each binary character is actually called a bit in technological vernacular and each hex character is called a nibble. Two hex characters next to each other (AB for example) is called a byte.

So now, finally, let's calculate the decimal value of a hexadecimal (base 16) number:

A35D16

First let's figure out the column values (Remember, we're working from right to left):
16^0 is 1 so the first column on the right is the one's column. The column next to it on the left is then the sixteens column. Then the two-hundred-fifty-six's column. Lastly on the far left we have the four-thousand-ninety-six's column.

So let's add it up:
(10*4096)+(3*256)+(5*16)+(13*1)=41821

This post may seem long and overwhelming but I've truly made it as short and sweet as possible. If you study it, you should be able to count in any base (including hexadecimal of course) in no time :) I truly hope this helps you :)



Edited 3 time(s). Last edit at 02/21/2010 04:43PM by Arikado.
Re: Having a bit of trouble learning hexadecimal...
February 21, 2010 07:15AM
Wow, you explained Hex in a similar way to how I explain it to people, except in a much better way that even made it easier for me to add Hex in my head (although it is still MUCH easier for me if I have it typed/written out in front of me)
Re: Having a bit of trouble learning hexadecimal...
February 21, 2010 07:18PM
So, to check that I understand correctly:

F8C16 = (15*256) + (8*16) + (12*1) = 398010 ?
Re: Having a bit of trouble learning hexadecimal...
February 21, 2010 07:28PM
Correct :-)
Re: Having a bit of trouble learning hexadecimal...
February 21, 2010 07:42PM
Woohoo, I get it! Thanks a lot, guys! =D
Sorry, only registered users may post in this forum.

Click here to login