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 | ||
---|---|---|

Binary | Decimal | Hex |

0000 | 0 | 0 |

0001 | 1 | 1 |

0010 | 2 | 2 |

0011 | 3 | 3 |

0100 | 4 | 4 |

0101 | 5 | 5 |

0110 | 6 | 6 |

0111 | 7 | 7 |

1000 | 8 | 8 |

1001 | 9 | 9 |

1010 | 10 | A |

1011 | 11 | B |

1100 | 12 | C |

1101 | 13 | D |

1110 | 14 | E |

1111 | 15 | F |

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 | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

x0 | x1 | x2 | x3 | x4
| x5 | x6 | x7 | x8 | x9 | xA
| xB | xC | xD | xE | xF | |

0x | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

1x | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |

2x | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |

3x | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |

4x | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |

5x | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |

6x | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 |

7x | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 |

8x | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |

9x | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 |

Ax | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 |

Bx | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 |

Cx | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |

Dx | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 |

Ex | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 |

Fx | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 |

**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 |

1000 | + | 700 | + | 30 | + | 5
| = | 1,735 |

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 |

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 | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

32768 | 16384 | 8192 | 4096 | 2048 | 1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |

- 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.

Use your browser's **Back** control to return to the previous page.

Copyright © 2000 - 2002

San Diego, California

Last Updated: