View Full Version : How does the hexadecimal system work?

SpiritualStorms

07-06-2004, 05:43 AM

I have been thinking for a while as to how the 6 digit system for the hexidecimal works. I dont get how it is that one can get 256 colors from merely 6 digits. If i take a calculator, and i multiply 6 times 16, i get only 96 different potential variations, so how can that be the same as 256? I know theres 0 through 9, and from there, its like A through F for anything higher than 9. Thus, i know that #000000 is like pure for pure black. For white, its #ffffff. But i do not get from this, how it is that it can be 256 colors.

Can anyone lend a hand, or an explanation?

Willy Duitt

07-06-2004, 05:48 AM

Your not very good at math are you?

SpiritualStorms

07-06-2004, 05:54 AM

LOL............never been my greatest skill. I am a visual person, so i try to visualise concepts so that i may understand them. If i however multiply 16 times 16, then i get 256. Is that how its supposed to be?

neofibril

07-06-2004, 06:19 AM

The Hexadecimal Number System (http://www.math.ohiou.edu/~just/hex.htm)

SpiritualStorms

07-07-2004, 03:49 AM

So is anyone gonna answer my question? Is it 16 times 16?

JohnKrutsch

07-07-2004, 05:49 AM

They all ready did. The link that neofibril supplied more than adequately explained how The Hexadecimal Number System works.

And yes 16*16=256 :D

SpiritualStorms

07-07-2004, 06:06 AM

I didnt really understand the excercises. I get the idea of how the letters represent higher digits than 9, but over, and beyond that, i didnt get a friggin thing. I need things broken down before i get things.

Garadon

07-07-2004, 07:15 AM

the hexadecimal system works just like the normal 10 base system.

the first hex on the left of a number is 1's so a number with only 1 digit can be between 0 and 15(f):0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f

the next digits is then increased for every time you have 16 or more of the digit before it so 16 would be :16=#10,17=#11,18=#12.

a color code hex number is infact not 1 number but 3hex numbers.

2 digits for red

2 digits for green

2 digits for blue

each number can be between 0-255. this can be calculated by saying that you can store 16 sixteen times with to digits 16x16=256 but since 1 number i zero the range is 0-255.

each of the 3 numbers(red,green,blue) indicates how much of that color to put in the final color. And as standard it was decided in the way way past that a 0 of all three(#00{red}00{green}00{blue} should black and a full of all 3(#ff{red}ff{green}ff{blue}should be white.

And contrary to what you said this system allows for 256^3 different colors not just 256 colors.

Hope that helped.

SpiritualStorms

07-07-2004, 11:53 AM

See what kills me is the idea of a set. I know that 10 is really 16, since f is 15. In this sense, the one is for a single set, while, the zero is for nothing left over.

This is ok up until i get to something like 26. If i say, its 2 sets, plus a 6, then i would be inclined to think, ok, thats 30 plus 6, which is 36, but that isnt correct either. Hence, from my perspective, there isnt an easy way of using a formula in my head by which to easily figure out how to go from regular math notation to hexadecimal notation.

For something like FF, i know the answer is 240 plus 15, since the first letter means 15 times 16, which gives us 240. The second F means 15, so when you add 240 plus 15, you get 255. But i dont see how to apply a consistant formula all accross the board. This is why i dont fully get it.

How do i break something like, 24 for red, 26 for green, and 24 for blue. How do i break down into their hexadecimal equivalents? In other words, how do i do it automatically in my head without having to like count with my toes. If i write everything down, then yea, i could figure out. But i dont always want to have to write things down.

At any rate, if in human terms the number is 24, i add 6 to get 30, which would be the hexadecimal equivalent. But if the hexadecimal is like lets 56, then i subtract 6, and i get 50, for the human notation version of the number.

Somehow, anything after F, you have to add a 6 to get an idea of the hexadecimal equivalency. 14 then is like 20 since i have added a 6. But how do i figure out something like 35 in hexadecimal notation? I subtract, right? and i subtract 6 since, the differences between regular sets, and hexadecimal sets is 6. If you go from human notation to hexadecimal, you add a 6, but if you go from hexadecimal to human, you subtract a 6.

But how do i do an easy translation of something like BB? Or ED? What B= 11, but how then do i understand the 11? If i had to just do math, i would probably be inclined to just ad 6, but that isnt correct since the 11 here means 11 sets of something, which is 16. This being the case, i know then that i multiply 11 sets times 16 to get 176; and from here, we add another 11 for the second b to get the final answer of 187?

I am not sure i am phrasing my problem. i know that the second digit generally presents a set, hence, 10 means a whole set of 15---if the 10 here in the hex system, and not in the human system. In the human system, 10 is anything over 9, but in hex, its anything after F, which is 16. But supposing i was already in the hex system: how would i do 255? Do i simply subtract 6 to get 249? Is this correct? 249 is the human version of the hex system of 255?

nolachrymose

07-07-2004, 01:21 PM

It's all about place values. But just to preface, it doesn't make sense to call the decimal system the "human" system. Hexadecimal is just as much a human base as decimal.

When you have a number in decimal, say, 456, each digit represents a place value. Here, "6" is the "units" digit (1), so you multiply 6*1. Then, "5" is the "tens" digit (10), so you multiply 5*10. Then, "4" is the hundreds digit (100), so you multiply 4*100. The sum of these products is equal to the number itself.

The reason we do this is because each digit is "mapped" to a power of ten, starting from 0. The "6" is in the place value 10^0, or 1. The "5" is in the place value 10^1, or 10. The "4" is in the place value 10^2, or 100.

What does this mean in terms of hexadecimal, though?

When you use a different base system, it's very simple to convert to decimal. All you do is switch the base in the above example to the base you are using (in your case, 16). So, for instance, if we have the number 255 in hexadecimal, the conversion process to decimal would be this:

5 * 16^0 = 5*1 = 5

5 * 16^1 = 5*16 = 80

2 * 16^2 = 2*256 = 512

Then, we take the sum (5 + 80 + 512) and we get 597. That is the decimal value of the hex. number 255.

Hope that helps!

Happy coding! :)

dumpfi

07-07-2004, 01:38 PM

This is ok up until i get to something like 26. If i say, its 2 sets, plus a 6, then i would be inclined to think, ok, thats 30 plus 6, which is 36, but that isnt correct either.

26 => 2 full sets + 6 left over => 2 * 16 + 6 = 38

How do i break something like, 24 for red, 26 for green, and 24 for blue. How do i break down into their hexadecimal equivalents? In other words, how do i do it automatically in my head without having to like count with my toes. If i write everything down, then yea, i could figure out. But i dont always want to have to write things down.Use a calculator, if you aren't good enough in multiplication and addition. :D

But if the hexadecimal is like lets 56, then i subtract 6, and i get 50, for the human notation version of the number. (hex) 56 => 5 full sets + 6 left over => (dec) 5 * 16 + 6 = 86

(dec) 86 => FLOOR(86 / 16) full sets + 86 % 16 left over => (hex) 5 * 10 + 6 = 56

But how do i do an easy translation of something like BB? Or ED? What B= 11, but how then do i understand the 11? If i had to just do math, i would probably be inclined to just ad 6, but that isnt correct since the 11 here means 11 sets of something, which is 16. This being the case, i know then that i multiply 11 sets times 16 to get 176; and from here, we add another 11 for the second b to get the final answer of 187?

BB => 11 full sets + 11 left over => 11 * 16 + 11 = 187

ED => 14 full sets + 13 left over => 14 * 16 + 13 = 237

But supposing i was already in the hex system: how would i do 255? Do i simply subtract 6 to get 249? Is this correct? 249 is the human version of the hex system of 255?

255 => 2 full sets of full sets + 5 full sets + 5 left over => 2 * 16 * 16 + 5 * 16 + 5 = 597

dumpfi

trib4lmaniac

07-07-2004, 02:16 PM

If i take a calculator, and i multiply 6 times 16, i get only 96 different potential variations

lol... that's a far cry from the 16 and a half million combinations available!

dumpfi

07-07-2004, 02:21 PM

lol... that's a far cry from the 16 and a half million combinations available!Actually, 6 times 16 is 96. :D

Next time he should try 16^6. :p

dumpfi

trib4lmaniac

07-07-2004, 02:46 PM

You know what I mean :D

SpiritualStorms

07-08-2004, 12:35 AM

I realise that. All languages are human made, hence human based. However, because some times one needs to create distinctions for effective communication, i chose a set of terms that would contrast the 2 for easier references.

from: nolachrymose,

It's all about place values. But just to preface, it doesn't make sense to call the decimal system the "human" system. Hexadecimal is just as much a human base as decimal.

It helps some times when one uses gimmick like thought structures to differenciate one thought from another.

SpiritualStorms

07-08-2004, 01:23 AM

LOL......Looks like everyone is having fun at my expense. Here's a quote from the link neo gave me:

CORRECT!

OK, we have established that the hexadecimal digits 0--F correspond to our familiar decimal numbers 0--15. But how shall we represent the number 16? Note that this is the point where Hexans run out of fingers. Of course, we humans run into the same problem when we get to 9 + 1. Some of our ancestors hit upon an ingenious solution: Let's write the next number after 9 as 10, which can be interpreted as: "1 full set of (10) digits and 0 leftovers", or "1 x 10 + 0" for shorthand. Of course, a Hexan would be inclined to think of "1 full set of digits and 0 leftovers" rather as "1 x 16 + 0", which is exactly the number that comes after "F"!

Thus, the decimal number 16 will be represented as 10 in the hexadecimal system. Our number 17, which is "1 full set of digits and 1 leftover" to a Hexan will be represented as 11 in the hexadecimal system, and so on.

What is the meaning of the decimal number 21 to a Hexan?

The above, just in case anyone is interested is gotten from the following link:

http://www.math.ohiou.edu/~just/hex.htm#Q3A0S0

At any rate, so i sat out to write my own thoughts, and this is what i got:

0 = 0;

1 = 1;

2 = 2;

3 = 3;

4 = 4;

5 = 5;

6 = 6;

7 = 7;

8 = 8;

9 = 9;

A = 10;

B = 11;

C = 12;

D = 13;

E = 14;

F = 15;

The above is how 16 different possibilities are represented in the Hexadecimal system. But the question some will have is how then do epresent anything that is higher than 15? To answer this, you will have first think about how we in the real world go over and beyond 9. Recall from life that there's really only 9 different numbers. Anything beyond 9 is some what of a repeat of all those nine numbers, with the exception that you simply add more digits the higher you go. For this reason, we have 1 and 0 to represent 10, which is the next number after 9. If we wanted to represent 17, in our real world situations, we simply say, 1, and 7, for one set of 9s, and 7 more after words. This is the meaning of 17 literally. Once we hit anything over 19, we simply increase the second number to a 2, thus giving us, 20. It is not until the second digit hits anything higher than 9, that we add another digit to give us 100. It makes sense doesnt, since, 99 is the highest you can go. Thus, if we want to go higher than 99, we must add a 3rd digit, and write it as 100.

Well, in a similar manner, you can say the same thing when it comes to the hexadecimal system. Instead of just using more letters, we simply add another digit to anything higher than F, since F represents 15. To do this, we simply write 10. The one represents a single set. The set, as you recall, is 15. That's the maximum that you will have, before you begin another round-up. This being the case, we know then that 10 is not literally 10, but rather one complete set of 15 numbers, with nothing remaining. What this means then is that 11 will be 17 since 10 is 16, and 15 is F. This might seem like a rather confusing system, but if you think about it, all we have done in a certain sense is increase the number set from our world to include 15, instead of just 9.

12 = 18;

13 = 19;

14 = 20;

15 = 21;

16 = 22;

17 = 23;

18 = 24;

19 = 25;

20 = 26;

21 = 27;

22 = 28;

23 = 29;

24 = 30;

25 = 31;

26 = 32;

As you can see, somewhere in the above, my logic fell apart. Take for example 20 in decimal, and 26 in hex. Do you see how its supposed to be 2 sets, plus zero left over? And yet, instead of saying 32 i wrote 20 = 26. If the 2 is supposed to mean 2 sets, then logic dictates that should be written as 2 * 16 = 32.

SpiritualStorms

07-08-2004, 03:38 AM

from nolachrymose,

What does this mean in terms of hexadecimal, though?

When you use a different base system, it's very simple to convert to decimal. All you do is switch the base in the above example to the base you are using (in your case, 16). So, for instance, if we have the number 255 in hexadecimal, the conversion process to decimal would be this:

5 * 16^0 = 5*1 = 5

5 * 16^1 = 5*16 = 80

2 * 16^2 = 2*256 = 512

Then, we take the sum (5 + 80 + 512) and we get 597. That is the decimal value of the hex. number 255.

Hope that helps!

When you say 16^0, you mean 16 to the zero power, which is similar to 16 * 0, correct? I am not sure I understand 5*16^0 =5*1 = 5. I am wondering where the hell the one came from. If i had to rewrite your example, i would be inclined to do something like, 5*16^0 =5, since 16 times zero is simply zero.

This is giving me a headache.

SpiritualStorms

07-08-2004, 07:25 AM

Well, i forgot that its a 16 base thingy, and not a simple 9 base digit thingy:

dumpfi:

Actually, 6 times 16 is 96.

Next time he should try 16^6.

So its 16 times 16 for the 256 thingy. Sue me.

Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.