hexadecimal system

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

can some one please explain what the letters and numbers are assigned what? when i count them i always seem to miss a number

0=1
1=2
2=3
3=4
4=5
5=6
6=7
7=8
8=9
9=10
a=11
b=12
c=13
d=14
e=15
f=16

where did the 0 go?

or is it

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

where did the 16 go?

how do they work? and hwo are they assigned?

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I think it's the second one. There is no "16". In all, there's sixteen elements (including zero). Wink

He has: 1,016 posts

Joined: May 2002

Abhi is correct, the hexdecimals are from 0 (0) to 15 (F). However, this is only for the last hexdecimal if you have a few next to eachother. For example..

A = 10 x 1 = 10
F = 15 x 1 = 10
10 = 1 x 16 + 0 x 1 = 16
20 = 2 x 16 + 0 x 1 = 32
A5 = 10 x 16 + 5 x 1 = 160
FF = 15 x 16 + 15 x 1 = 255
100 = 1 x 256 + 0 x 16 + 0 x 1 = 256
FE5 = 15 x 256 + 14 x 16 + 5 x 1 = 4069

And so on...

He has: 296 posts

Joined: May 2002

I have another question about hexidecimals. How does the byte count go up? I've never understood that part.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

byte count?

He has: 296 posts

Joined: May 2002

Quote:
A = 10 x 1 = 10
F = 15 x 1 = 10
10 = 1 x 16 + 0 x 1 = 16
20 = 2 x 16 + 0 x 1 = 32
A5 = 10 x 16 + 5 x 1 = 160
FF = 15 x 16 + 15 x 1 = 255
100 = 1 x 256 + 0 x 16 + 0 x 1 = 256
FE5 = 15 x 256 + 14 x 16 + 5 x 1 = 4069

[James Logsdon]

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Oh, well one hex digit is equal to 16 decimal. So, instead of the place holders being multiples of 10 decimal, their multiples of 16 decimal...

digits across top
number system down side
decimal value in table

system^digit = decimal value

+-----+---------+-------+------+-----+----+---+
|     |       5 |     4 |    3 |   2 |  1 | 0 |
+-----+---------+-------+------+-----+----+---+
| Bin |      32 |    16 |    8 |   4 |  2 | 1 |
+-----+---------+-------+------+-----+----+---+
| Dec |  100000 | 10000 | 1000 | 100 | 10 | 1 |
+-----+---------+-------+------+-----+----+---+
| Hex | 1048576 | 65536 | 4096 | 256 | 16 | 1 |
+-----+---------+-------+------+-----+----+---+
'

Mark Hensler
If there is no answer on Google, then there is no question.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Slightly off topic, but I love this shirt:
http://www.thinkgeek.com/tshirts/frustrations/5aa9/

He has: 1,016 posts

Joined: May 2002

HAHA. That's a cool shirt. Laughing out loud
For those of you that don't understand binary, 10 = 2
(if now that made any sense, LOL!)

Laughing out loud:D

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

That's a great T-shirt and yes I did get it without explaination! Wink

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

then how come 16 x 16 = 256? is it coincidence or what?
if a 16 does excist then where is it?
and how do u convert from RGB to hexadecimal and back again?

.. o and btw i dont' get the t-shirt thingy...

He has: 1,016 posts

Joined: May 2002

Ok, think about it this way.. each char in a hex goes from 0 (0) to F (15) so that's basically 16 numbers (if you count A-F as numbers). Now, if you put 2 hexadecimals next to eachother (i.e. A5 (we'll call them "left" and "right")). Since 2 hex are and the right number can only go as high as 15, the left one will be the next number in like which is 16. So...

0F = 15 (0 x 16 + 15)
10 = 16 (1 x 16 + 0)
35 = 53 (3 x 16 + 5)
AA = 170 (10 x 16 + 10)
F0 = 240 (15 x 16 + 0)
FF = 255 (15 x 16 + 0)

Ok, so we're done with 2 hex next to eachother and notice that FF is 255 and of course the next number is 256 (16x16) which means that if Hex the next number would be 100 (1 x 256 + 1 x 16 + 0)

I hope that makes more sense now...

The Webmistress's picture

She has: 5,586 posts

Joined: Feb 2001

Now that's confused me!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

lets learn to count:

+-----+------+-----+     +-----+-----------+-----+
| dec | bin  | hex |     | dec | bin       | hex |
+-----+------+-----+     +-----+-----------+-----+
|   0 |    0 |   0 |     |  16 | 0001 0000 |  10 |
|   1 |    1 |   1 |     |  17 | 0001 0001 |  11 |
|   2 |   10 |   2 |     |  18 | 0001 0010 |  12 |
|   3 |   11 |   3 |     |  19 | 0001 0011 |  13 |
|   4 |  100 |   4 |     |  20 | 0001 0100 |  14 |
|   5 |  101 |   5 |     |  21 | 0001 0101 |  15 |
|   6 |  110 |   6 |     |  22 | 0001 0110 |  16 |
|   7 |  111 |   7 |     |  23 | 0001 0111 |  17 |
|   8 | 1000 |   8 |     |  24 | 0001 1000 |  18 |
|   9 | 1001 |   9 |     |  25 | 0001 1001 |  19 |
|  10 | 1010 |   A |     |  26 | 0001 1010 |  1A |
|  11 | 1011 |   B |     |  27 | 0001 1011 |  1B |
|  12 | 1100 |   C |     |  28 | 0001 1100 |  1C |
|  13 | 1101 |   D |     |  29 | 0001 1101 |  1D |
|  14 | 1110 |   E |     |  30 | 0001 1110 |  1E |
|  15 | 1111 |   F |     |  31 | 0001 1111 |  1F |
+-----+------+-----+     +-----+-----------+-----+
'

Mark Hensler
If there is no answer on Google, then there is no question.

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

is this the dark side of hexadecimal?

why does FF = 256?

and 00 == 00?

:S somethings is very wrong here (IMO)

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

You think zero shouldn't equal zero?

He has: 1,016 posts

Joined: May 2002

FF = 255 not 256...

FF = 255 because of the reason I explained earlier. The left F is 15 x 16 = 240 and the right F is 15 x 1 = 15 which makes 240 + 15 = 255.

00 = 0 because the left 0 is 0 x 16 = 0 and the right 0 is 0 x 1 = 0 which makes 0 + 0 = 0.

He has: 296 posts

Joined: May 2002

Wow! It all makes some kinda sense to me now! Thanks y'all!

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

how come i still don't get it? :S

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.