Hexidecimal Numbering Tutorial The basic unit of value in a computer is the bit. A bit may have a value of 0 or 1. Larger numbers are represented by groupings of one's and zero's. The following chart shows how 4 bits may be grouped for the numbers 0 throuth 15. The third column in the chart shows the hexidecimal (abbreviated hex) number for each grouping.

Numbering Chart
BinaryDecimalHex
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
101010A
101111B
110012C
110113D
111014E
111115F

Since we only have digits up to 9 in our common numbering system, the values for 10 - 15 are represented using the letters A - F in hex. These are the 16 possible values available; hence the name hexi (6) decimal (10).

Computer data is commonly grouped in a byte which consists of 8 bits. Since 8 one's and zero's is a little hard for humans to work with, a byte is commonly represented by two hex digits. It is easier to say and remember "thirty seven hex" than "zero zero one one zero one one one binary". Each hex digit (4 bits) of a byte is sometimes referred to as a nibble.

The following chart can be used to convert a two digit hexidecimal number to its decimal equivalent. Use the most significant digit along the left side to select the row and the least significant digit along the top to select the column. Their intersection in the table is the equivalent decimal value. For example, 45 hex is equal to 69 decimal. D7 hex is equal to 215 decimal.

Hexidecimal to Decimal Conversion Chart
x0x1x2x3x4 x5x6x7x8x9xA xBxCxDxExF
0x012345678 9101112131415
1x1617181920212223 2425262728293031
2x3233343536373839 4041424344454647
3x4849505152535455 5657585960616263
4x6465666768697071 7273747576777879
5x8081828384858687 8889909192939495
6x96979899100101102103 104105106107108109110111
7x112113114115116117118119 120121122123124125126127
8x128129130131132133134135 136137138139140141142143
9x144145146147148149150151 152153154155156157158159
Ax160161162163164165166167 168169170171172173174175
Bx176177178179180181182183 184185186187188189190191
Cx192193194195196197198199 200201202203204205206207
Dx208209210211212213214215 216217218219220221222223
Ex224225226227228229230231 232233234235236237238239
Fx240241242243244245246247 248249250251252253254255

Powers of 10:

In the decimal or base 10 system, counting is done by powers of ten. That is: units, tens, hundreds, thousands, etc. In decimal, the number 1,735 can be described as:

 Thousands Hundreds Tens Ones 1 7 3 5
Which works out to be:
 1000 + 700 + 30 + 5 = 1,735

Powers of 2:

The same concept is true for binary or base 2 used by computers. That is: one, two, four, eight, sixteen, etc. The only difference is we need more positions in the number. So, 1,735 in binary is:

 2048 1024 512 256 128 64 32 16 8 4 2 1 0 1 1 0 1 1 0 0 0 1 1 1
Which is:
 1024 + 512 + 128 + 64 + 4 + 2 + 1 = 1,735

To convert this binary number to hexidecimal, group them by 4 bits per group and use the numbering chart.

 0 1 1 0 1 1 0 0 0 1 1 1 = 6C7

The largest value a byte can hold is 255. To hold larger values, two bytes are grouped into a word. A 16 bit word can hold a value up to 65,535 decimal or FFFF hex.

Decimal to Hexidecimal:

Powers of 2 Chart
32768163848192409620481024512256 1286432168421
Use this method to convert a number from decimal to hexidecimal.
1. Write the number to be converted on a piece of paper.
2. Subtract the highest power of 2 from the number so the remainder will be positive.
3. Mark a 1 under this power of 2 in the above table.
4. Repeat steps 2 and 3 for the remainder value until the remainder is zero.
5. For all unused powers of 2, mark a 0 under the table.
6. Group the resulting 1's and 0's by 4 bits per group and lookup the hexidecimal number for each group.
So for the decimal value 1,735 we do the following:
 1735 -1024 Mark 1 for this power. 711 -512 Mark 1 for this power. 199 -128 Mark 1 for this power. 71 -64 Mark 1 for this power. 7 -4 Mark 1 for this power. 3 -2 Mark 1 for this power. 1 -1 Mark 1 for this power. 0
 0 0 0 0 - 0 1 1 0 - 1 1 0 0 - 0 1 1 1 = 06C7

An even easier way to do this conversion is to get yourself a "programmers" calculator which has buttons to convert from one number base to another. The Windows calculator, located in the accessories menu, also provides this function for binary, octal, decimal, and hexidecimal. Choose "Scientific" from the Windows calculator View menu bar item.

Modulo:
Modulo is the remainder portion of a division operation. For example, 8 modulo 3 is 2. (8 / 3 = 2 with a remainder of 2.) This is a useful operation that guarantees the remainder or modulo value will always be smaller than the modulo base (divisor) number. For example, a modulo 8 result will never be larger than a 3 bit value. The highest remainder possible for the division of any number by 8 is 7.

A checksum value for a number of bytes can be computed in this manner. All bytes are first summed and then the modulo 256 of this sum is computed. We choose modulo 256 in this example to ensure that the checksum value can be represended by a byte value (8 bits). The modulo 256 operation divides the summed bytes by 256 and provides the remainder of this operation as the final result. The quotent portion of the division operation is discarded. 