6.2

Hexadecimal Numbers

 

6.2.1

Hexadecimal numbers as MAC addresses

You have already studied the decimal and binary numbering systems. Decimal numbers express a Base 10 system, and binary numbers express a Base 2 system. Another numbering system you need to learn is the hexadecimal (hex) or base 16 system. You will learn about the hex numbering system on the following pages. Hex is a shorthand method for representing the 8-bit bytes that are stored in the computer system. It was chosen to represent identifiers because it can easily represent the 8-bit byte by using only two hexadecimal symbols.

MAC addresses are 48 bits in length and are expressed as twelve hexadecimal digits. The first six hexadecimal digits, which are administered by the IEEE, identify the manufacturer or vendor and thus comprise the Organizational Unique Identifier (OUI). The remaining six hexadecimal digits comprise the interface serial number, or another value administered by the specific vendor. MAC addresses are sometimes referred to as burned-in addresses (BIAs) because they are burned into read-only memory (ROM) and are copied into random-access memory (RAM) when the NIC initializes.

 

6.2

Hexadecimal Numbers

 

6.2.2

Basic hexadecimal (hex) numbering

Hexadecimal is a Base 16 numbering system that is used to represent MAC addresses. It is referred to as Base 16 because it uses sixteen symbols; combinations of these symbols can then represent all possible numbers. Since there are only ten symbols that represent digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), and the Base 16 requires six more symbols, the extra symbols are the letters A, B, C, D, E, and F.

The position of each symbol, or digit, in a hex number represents the base number 16 raised to a power, or exponent, based on its position. Moving from right to left, the first position represents 160, or 1; the second position represents 161, or 16; the third position, 162, or 256; and so on.

Example:
4F6A = (4 x 163)+ (F[15] x 162)+ (6 x 161)+ (A[10] x 160) = 20330 (decimal)

 

6.2

Hexadecimal Numbers

 

6.2.3

Converting decimal numbers to hexadecimal numbers

As with binary numbers, converting from decimal to hex is done with a system called the remainder method. In this method we repeatedly divide the decimal number by the base number (in this case 16). We then convert the remainder each time into a hex number.

Example:
Convert the decimal number 24032 to hex.

24032/16

=

1502, with a remainder of 0

1502/16

=

93, with a remainder of 14 or E

93/16

=

5, with a remainder of 13 or D

5/16

=

0, with a remainder of 5

By collecting all the remainders backward, you have the hex number 5DE0.

 

6.2

Hexadecimal Numbers

 

6.2.4

Converting hexadecimal numbers to decimal numbers

Convert hexadecimal numbers to decimal numbers by multiplying the hex digits by the base number of the system  (Base 16) raised to the exponent of the position.

Example:
Convert the hex number 3F4B to a decimal number. (Work from right to left.)

3 x 163

=

12288

 

F(15) x 162

=

3840

 

4 x 161

=

64

 

B(11) x 160

=

11

 

_________________

 

 

16203

= decimal equivalent

 

6.2

Hexadecimal Numbers

 

6.2.5

Methods for working with hexadecimal and  binary numbers

 

Converting binary to hexadecimal and hexadecimal to binary is an easy conversion. The reason is that base16(hexadecimal) is a power of base 2(binary). Every four binary digits (bits) are equal to one hexadecimal digit. The conversion looks like this:

Binary

 

Hex

Binary

 

Hex

0000

=

0

1000

=

8

0001

=

1

1001

=

9

0010

=

2

1010

=

A

0011

=

3

1011

=

B

0100

=

4

1100

=

C

0101

=

5

1101

=

D

0110

=

6

1110

=

E

0111

=

7

1111

=

F

So if we have a binary number that looks like 01011011, we break it into two groups of four bits. These look like this: 0101 and 1011. When you convert these two groups to hex, they look like 5 and B. So converting 01011011 to hex is 5B. To convert hex to binary do the opposite. Convert hex AC to binary. First convert hex A which is 1010 binary and then convert hex C which is 1100 binary. So the conversion is hex AC is 10101100 binary.

No matter how large the binary number, you always apply the same conversion. Start from the right of the binary number and break the number into groups of four. If at the left end of the number it doesn't evenly fit into a group of four, add zeros to the left end until it is equal to four digits (bits). Then convert each group of four to its hex equivalent. Here is an example:

100100100010111110111110111001001

converts to:

0001

0010

0100

0101

1111

0111

1101

1100

1001

converts to:

1

2

4

5

F

7

D

C

9

so:

 

 

100100100010111110111110111001001 Binary = 1245F7DC9 hex

As stated before hex works in exactly the opposite way. For every one hex digit, you convert it to four binary digits (bits). For example:

AD46BF

converts to:

 

 

 

A

D

4

6

B

F

converts to:

 

 

 

1010

1101

0100

0110

1011

1111

so:

 

 

AD46BF hex converts to 101011010100011010111111 binary

That is the conversion for binary to hexadecimal and from hexadecimal to binary.