Hexadecimal is 16 based and uses the digits 0 to 9 and the letters a to f to represent the values 0 to 15. Letters are used after values past nine as two digits can not be used. Hexadecimal is used more often than octal as any four bits of a binary number can be converted into its hexadecimal equivalent and vice-versa. The number 345 in hexadecimal is 837 as a decimal.
162 = 256
161 = 16
160 = 1
3 4 5 3x256 = 768
4x16 = 64
5x1 = 5
Another example using 2 bits is d9, which is 217 in decimal (Note: d in hexadecimal = 13 in decimal)
161 = 16
160 = 1
d 9 13x16 = 208
9x1 = 9
An eight bit binary number can be converted into its hexadecimal equivalent easily. For example, convert 11111111 into hexadecimal. (The answer is ff).
- Break the number into two lots of four bits: 1111 1111
- Convert each lot into its decimal equivalent: 1111 => 15, 1111 => 15
- Convert these into hex: 15 => f, 15 => f.
- Concatenate them: f and f => ff.
Hexadecimal works well with binary because 4 bits is half of a byte and bytes are one of the basic binary measuring units. E.g. Kilobytes, Megabytes, Gigabytes. Hexadecimal is often used as a more concise way of expressing a large binary number.
Use of the HEX system in Computers
A. The new Internet Protocol (version 6) system uses 128 bits and hexadecimal is used to abbreviate this very large number. Also, MAC numbers for internet adapters use 48 bits and are expressed in hexadecimal. An example MAC address is C4 46 19 73 49 70. To see the IP address and MAC number of a Windows computer open a command prompt and type ipconfig /all, then Enter. The MAC number is the physical address reading.
B. Computer monitors use a red, green and blue colour system.This is also know as RGB for short. Each pixel on the screen is a combination of different strengths of each of the three colours. In a 24 bit colour system a byte, 8 bits (24/3 = 8), is used for each colour. The maximum value a byte can hold id 28 - 1 = 255 (take 1 away to allow for zero). A value of 255, or ff in hex, means the colour is used at its full strength. A value of 0, or 00 in hex, means none of the colour is used in the overall mix of colours. Note: upper or lower case letters can be used when writing hex, so ff is equivalent to FF.
C. In HTML red, green and blue colour values are often expressed in hexadecimal. There are six hex numbers in a colour; two for each colour. Reading from the left the first two represent the strength/amount of red in the colour, the next two the strength of the green and the last two the strength of the blue.