TUCoPS :: PC Hacks :: hex.txt Hexadecimal Counting
```
_|_|_|  _|        _|     _| _|     _|  _|     _|    _|_|_|   _|      _|_|_|
_|      _|      _|  _|  _| _| _|  _| _| _|  _|  _|  _|   _|  _|      _|
_|_|    _|      _|_|_|  _|    _|  _|    _|  _|_|_|  _|_|_|   _|      _|_|
_|      _|      _|  _|  _|    _|  _|    _|  _|  _|  _|   _|  _|      _|
_|      _|_|_|  _|  _|  _|    _|  _|    _|  _|  _|  _|_|_|   _|_|_|  _|_|_|

_|_|_|   _|  _|  _|_|_|  _|_|_|  _|_|_|  _|_|_|
_|   _|  _|  _|  _|      _|      _|      _|
_|_|_|   _|_|_|  _|_|    _|      _|_|    _|_|_|
_|       _|  _|  _|      _|      _|          _|
_|       _|  _|  _|_|_|  _|_|_|  _|_|_|  _|_|_|

http://www.pheces.org
"Can ya taste the waste?"

öööööööööööööööööööööööööööööööö

Title:      |||| Hexidecimal Counting ||||

Date:       February 19, 1998
Author:     rootwurm

öööööööööööööööööööööööööööööööö

Hexidecimal is base 16.  what this means is it can use up to 16 different digits. 0,1,2,3,4,5,6,
7,8,9,0,A,B,C,D,E,F

as you read in "Binary Counting" (if you didn't read it, do so, it makes this that much easier),
numbers are broken down into columns.

DCBA

the first column (A) always has a value of 1.  the second column (B), always has the value of the
base (in this case, 16).  and the rest of the columns have a value of the base multiplied by the
previous column. (remember, we're going from right to left)

here is the values of the columns in hexidecimal(or hex for short) just in case you don't fully
get it right now:

DCBA

A = 1    (always 1)
B = 16   (the base)
C = 256  (BASE x B)
D = 4096 (BASE x C)

and so on.

now that you know the values of each column, let's see how this teaches you hex.  now let me show
you how to count using letters. (very easy)

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

easy, huh?  now let's see how that can be used in figuring out the values of hex numbers...

we'll use 0x1B for example.  now, many times (but not always) there is a '0x' preceding the hex
number.  all you do is drop that 0x.  this leaves '1B' in the example above.

now you multiply the value of the digit by the value of the column it's in.

B is in the first column, and column one has a value of 1

B x 1 = 11

1 is in the second column, and column two has a value of 16

1 x 16 = 16

now simply add the two sums together

16 + 11 = 26

that's it!  so, 0x1B is equal to 26.  let me do a few more, just to be sure you've caught on.

0x3F
3F
F x 1 = 15
3 x 16 = 48
48 + 15 = 63
0x3F = 63

0x192
192
2 x 1 = 2
9 x 16 = 144
1 x 4096 = 4096
4096 + 144 + 2 = 4242
0x192 = 4242

alright, you should get the idea now.  practice with it for a while, and if you want to check
yourself, then windows calculator has a decimal to hex convertor.  just put it in scientific
view, then click on the DEC radio button, enter the number, and then click the HEX radio button
to check yourself.

some uses for hex numbers:

assembly language
writing the date in hex (pisses teachers off, i know from experiance :-)
just because it's cool

ok, now i'll count to twenty in hex:

0x0 = 0
0x1 = 1
0x2 = 2
0x3 = 3
0x4 = 4
0x5 = 5
0x6 = 6
0x7 = 7
0x8 = 8
0x9 = 9
0xA = 10
0xB = 11
0xC = 12
0xD = 13
0xE = 14
0xF = 15
0x10 = 16
0x11 = 17
0x12 = 18
0x13 = 19
0x14 = 20
0x15 = 21
0x16 = 22
0x17 = 23
0x18 = 24
0x19 = 25
0x1A = 26
0x1B = 27
0x1C = 28
0x1D = 29
0x1E = 30
0x1F = 31
0x20 = 32
0x22 = 33
0x23 = 34
0x24 = 35
0x25 = 36

TEST:  can you figure out what 0x29A is??

EOF

rootwurm (rootwurm@pheces.org)

(((((((((((((((((((((((((((((((((((((((((((((#yep)))))))))))))))))))))))))))))))))))))))))))))

```

TUCoPS is optimized to look best in Firefox® on a widescreen monitor (1440x900 or better).
Site design & layout copyright © 1986-2024 AOH