Hexadecimal numbers
Arabic numbers are based on the number 10.
There are 10 symbols (0..9) that we use to represent all numbers.
Hexadecimal numbers are based on the value 16. There are 16
symbols that are used to represent hex numbers - 0 through 9 then A through F
(after F, you have to carry).
The following is a list of alternating
Decimal and Hexadecimal values.
00 00 01 01 02 02 03 03 04 04 05 05 06 06 07 07
08 08 09 09 10 0A 11 0B 12 0C 13 0D 14 0E 15 0F
16 10 17 11 18 12 19 13 20 14 21 15 22 16 23 17
24 18 25 19 26 1A 27 1B 28 1C 29 1D 30 1E 31 1F
32 20 ..... etc etc
If you want to convert a base 10 number to a base 16 number (decimal to hex)
then repetitively divide the decimal number by 16 and keep track of the
remainder. Example: find the hex equivalent of the decimal number 106.
0
--- r 6
16 ) 6
------ r A
16 ) 106
The hex value 6A is equivalent to the decimal value 106.
Example 2: convert decimal 1000 to hex.
0
---- r 3
16 ) 3
---- r E (which is 14 decimal)
16 ) 62
------- r 8
16 ) 1000
The hex value of decimal 1000 is 3E8
Why Hex?
Why do we even USE hexadecimal numbers? Most computers,
in use today, utilize binary circuits. Everything (instructions and data) is
represented in binary. But displaying information in binary takes a lot of
digits. The 5 digit number 32767 is displayed as 11111111111111 (14 binary
digits). In hex, it would be 4 digits, 3FFF.
Converting from Binary
to Hexadecimal:
There is a nice correspondence between binary
numbers and hexadecimal numbers - exactly 4 binary digits make up 1 hex digit,
as shown in the following table. Binary Hex
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
So given the following binary number ...
10110110101010000101011101010001010101
... and starting on the right, divide the number up into groups of 4.
You can add leading zeros to the left most group, (to get 4 digits) if you want.
0010 1101 1010 1010 0001 0101 1101 0100 0101 0101
Look up each group of 4 in the table to see what the hex value is.
0010 1101 1010 1010 0001 0101 1101 0100 0101 0101
2 D A A 1 5 D 4 5 5
Usage:
When you are working with some technical software,
such as Norton Utilities, there are some modes where all of the information is
displayed in hex.
When working with web pages (in HTML), the colors can
be specified using hex numbers to specifiy the intensity of red, green and blue.
Example:
<font color="#928AB7"> red
green blue
Using
this scheme, there are 16,777,216 different colors that can be specified.