kidzsearch.com > wiki Explore:images videos games
Hexadecimal numeral system
The hexadecimal numeral system, also known as just hex, is a numeral system made up of 16 symbols (base 16). The standard numeral system is called decimal (base 10) and uses 10 symbols: 0,1,2,3,4,5,6,7,8,9. Hexadecimal uses the decimal numbers and includes six extra symbols. We do not have symbols that mean ten, or eleven etc. so these symbols are characters taken from the English alphabet: A, B, C, D, E and F. Hexadecimal A = decimal 10, and hexadecimal F = decimal 15.
Humans tend to use the decimal system. This is probably because humans have ten fingers (ten digits). Computers however, only have on and off, called a binary digit (or bit, for short). A binary number is just a string of zeros and ones: 11011011, for example. For convenience, engineers working with computers tend to group bits together. In earlier days, such as the 1960's, they would group 3 bits at a time (much like large decimal numbers are grouped in threes, like the number 123,456,789). Three bits, each being on or off, can represent the eight numbers from 0 to 7: 000 = 0; 001 = 1; 010 = 2; 011 = 3; 100 = 4; 101 = 5; 110 = 6 and 111 = 7. This is called octal.
As computers got bigger, it was more convenient to group bits together four at a time, instead of three at a time. The additional bit can be either on or off, a 0 or a 1. So this doubles the numbers that the group would represent. This is 16 numbers. Hex = 6 and Decimal = 10, so it is called hexadecimal. Four bits is called a nibble (sometimes spelled nybble). A nibble is one hexadecimal digit, and is written using a symbol 09 or AF. Two nibbles is a byte (8 bits). Most computer operations use the byte, or a multiple of the byte (16 bits, 24, 32, 64, etc.). Hexadecimal makes it easier to write these large binary numbers.
To avoid confusion with decimal, octal or other numbering systems, hexadecimal numbers are sometimes written with a "h" after the number. For example, 63h means 63 hexadecimal. Software developers quite often use 0x before the number (0x63).
Contents
Hexadecimal values
Hexadecimal is similar to the octal numeral system (base 8) because each can be easily compared to the binary numeral system. Hexadecimal uses a fourbit binary coding. This means that each digit in hexadecimal is the same as four digits in binary. Octal uses a threebit binary system.
In the decimal system, the first digit is the one's place, the next digit to the left is the ten's place, the next is the hundred's place, etc. In hexadecimal, each digit can be 16 values, not 10. This means the digits have the one's place, the sixteen's place, and the next one is the 256's place. So 1h = 1 decimal, 10h = 16 decimal, and 100h = 256 in decimal.
Example values of hexadecimal numbers converted into binary, octal and decimal.

Conversion
Binary to hexadecimal
Changing a number from binary to hex uses a grouping method. The binary number is separated into groups of four digits starting from the right. These groups are then converted to hexadecimal digits as shown in the chart above for the hexadecimal numbers 0 through F. To change from hexadecimal, the reverse is done. The hex digits are each changed to binary and the grouping is usually removed.
Binary  Groupings  Hex  

01100101  0110  0101  65  
010010110110  0100  1011  0110  4B6  
1101011101011010  1101  0111  0101  1010  D75A 
Hexadecimal and decimal
To convert a number from hexadecimal to decimal, there are two common ways.
The first method is more commonly done when converting it manually:
 Use the decimal value for each hexadecimal digit. For 09, it is the same, but A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.
 Keep a sum of the numbers converted at each step below.
 Start with the least significant hexadecimal digit. That is the digit on the right end. This will be the first item in a sum.
 Take the secondleast significant digit. That is next to the digit on the right end. Multiply the decimal value of the digit by 16. Add this to the sum.
 Do the same for the thirdleast significant digit, but multiply it by 16^{2} (that is, 16 squared, or 256). Add it to the sum.
 Continue for each digit, multiplying each place by another power of 16. (4096, 65536, etc.)
Location  

6  5  4  3  2  1  
Value  1048576 (16^{5})  65536 (16^{4})  4096 (16^{3})  256 (16^{2})  16(16^{1})  1 (16^{0}) 
The next method is more commonly done when converting a number in software. It doesn't need to know how many digits the number has before it starts, and it never multiplies by more than 16, but it looks longer on paper.
 Use the decimal value for each hexadecimal digit. For 09, it is the same, but A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.
 Keep a sum of the numbers converted at each step below.
 Start with the most significant digit (the digit on the far left). This is the first item in the sum.
 If another digit exists, multiply the sum by 16 and add the decimal value of the next digit.
 Repeat the above step until there are no more digits.
Example: 5Fh and 3425h to decimal, method 1


Example: 5Fh and 3425h to decimal, method 2

