Zebra0.com

computer-concepts numbersHexadecimal Numbers: Base 16

Hexadecimal Numbers: Base 16

4 binary digits can be represented by 1 hex digit.

Hexadecimal
If we write a large number as a binary number, it can be quite long.
The hexadecimal, (hex) base 16, is used because every 4 binary digits can be represented by one hexadecimal digit.
In binary, base 2, there are 2 digits: 0, 1.
In decimal, base 10, there are 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
In hexadecimal, base 16, there are 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

The table below shows the corresponding values of decimal, binary, and hexadecimal:

Decimal

Binary

Hexadecimal

0

0000

0

1

0001

1

2

0010

2

3

0011

3

4

0100

4

5

0101

5

6

0110

6

7

0111

7

8

1000

8

9

1001

9

10

1010

A

11

1011

B

12

1100

C

13

1101

D

14

1110

E

15

1111

F

To convert a binary number to hexadecimal, first break it into groups of 4 starting on the right. You can always add 0 on the left without changing the value of a number. If the left most group does not have 4 digits, just add zeroes on the left to make a group of 4. Then replace each group of 4 with the corresponding hexadecimal digit from the table above.
Example: Convert   10110111110112 to hexadecimal (base 16)
Break into groups of 4 starting on the RIGHT: 0001,0110,1111,1011
Write the hexadecimal digit for each group of 4:
0001,0110,1111,1011
1        6         F       B
There we have it: 10110111110112 = 16FB16
The place values in hexadecimal start with the ones place on the right, then multiply by 16 for each place moving to the left:

1,048,576

65,536

4096

256

16

1

165

164

163

162

161

160

The hexadecimal number 16FB is shown below with the place values:

4096

256

16

1

1

6

F

B

The decimal value is 1x4096 + 6x256 + 15x16 + 11x1.
Or: 4096 + 1536 + 240 +11, which is 5883.
Fortunately, we don't usually have to convert hexadecimal to decimal.


NEXT: Decimal, Binary and Hexadecimal