APCS – Unit 1- Lesson 5 – Hexadecimal and Conversions

1. What is Hexadecimal?

Just as we have ten digits in decimal or base 10 number system, two digits in binary or base 2 number system, hexadecimal is a base 16 number system. The values of a hexadecimal digit can be:

1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Therefore, the number 10 in base 10 would be represented as “A” in hexadecimal notation, 11 in base 10 would be represented as “B”, 12 in base 10 would be represented as “C”, etc.

2. How to convert hexadecimal to decimal?

The process is similar to the binary to decimal conversion from the previous lesson, except now the base is 16 instead of 2.

Example: Convert the hexadecimal number A2F7 to decimal.

3. How to convert decimal to hexadecimal?

Again, the process is similar to the decimal to binary conversion, except now the base is 16!

Example: Convert the decimal number 427 to hexadecimal.

4. How to convert hexadecimal to binary?

Hexadecimal number is 16 based, and 16 = 2^4. Therefore, each hexadecimal digit represents four binary digits. To convert a hexadecimal number to binary, convert each digit to four binary digits separately, pad zeros to the left if necessary, and then concatenate all the digits together.

Example: Convert the hexadecimal number 3AB2 to binary.

The answer is 0011101010110010.

5. How to convert binary to hexadecimal?

Converting binary to hexadecimal is the reverse of hexadecimal to binary conversion. First, starting from the right (lowest place value), divide the number into groups of four digits. Then convert each group of four binary digits into a hexadecimal digit separately. Finally, concatenate the results.

Example:

List of References:

  1. https://owlcation.com/stem/How-to-Convert-Hex-to-Binary-and-Binary-to-Hexadecimal
  2. cplusplus.com