No history yet

Data Representation Systems

Beyond Binary

Computers operate on binary, but long strings of 1s and 0s are cumbersome for people to read and write. To make things simpler, we often use other number systems to represent binary data more compactly. One of the most common is hexadecimal.

Hexadecimal, or 'hex', is a base-16 number system. This means it uses sixteen distinct symbols to represent values. It uses the familiar digits 0 through 9, and then adds the letters A through F to represent the values 10 through 15. The key reason hex is so useful in computing is that one hexadecimal digit can represent exactly four binary digits (a nibble). This makes conversion between the two systems incredibly straightforward.

DenaryHexadecimalBinary
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
10A1010
11B1011
12C1100
13D1101
14E1110
15F1111

Converting Between Systems

Being able to convert between denary, binary, and hexadecimal is a fundamental skill. To convert a hexadecimal number to denary, you multiply each digit by a power of 16. The rightmost digit is multiplied by $16^0$ (which is 1), the next digit to the left is multiplied by $16^1$ (which is 16), and so on. Then, you simply add the results together.

C716=(12×161)+(7×160)\text{C7}_{16} = (12 \times 16^1) + (7 \times 16^0)
=(12×16)+(7×1)=192+7=19910= (12 \times 16) + (7 \times 1) = 192 + 7 = 199_{10}

Converting from hexadecimal to binary is even easier. You just replace each hexadecimal digit with its 4-bit binary equivalent from the table above. It’s a direct substitution.

C716=1100C01117=110001112\text{C7}_{16} = \underbrace{1100}_{C} \underbrace{0111}_{7} = 11000111_2

Hex in the Wild

Hexadecimal isn't just an academic exercise; it's used everywhere in computing. One key application is in networking. Every device that connects to a network has a unique identifier burned into its hardware called a MAC address. This address is typically represented as six pairs of hexadecimal digits, like 00:1A:2B:3C:4D:5E.

Lesson image

You also see hexadecimal used extensively in web design and graphics to define colours. Colours on a screen are created by mixing different intensities of red, green, and blue light. An uses a six-digit hex code to specify the intensity of each of these three primary colours. For example, #FFFFFF is pure white (maximum intensity for all three colours), while #FF0000 is pure red.

Binary Operations

At the lowest level, a computer's processor is performing mathematical operations on binary numbers. Binary addition follows the same principles as denary addition, but the rules are simpler. You add column by column from right to left, carrying over when a sum exceeds 1.

The rules are: $0 + 0 = 0$ $0 + 1 = 1$ $1 + 0 = 1$ $1 + 1 = 0$, carry 1 $1 + 1 + 1 = 1$, carry 1

\begin{array}{@{}c@{\;}c@{}c@{}c@{}c@{}c} \\ & & 1 & 1 & 1 & \\ & & 1 & 0 & 1 & 1 \ & + & 0 & 1 & 1 & 0 \ \hline \\ & 1 & 0 & 0 & 0 & 1 \\ \end{array}

Computer processors work with a fixed number of bits, often stored in an 8-bit register. This limitation can cause a problem called an . This occurs when the result of a calculation is too large to fit into the available number of bits. For example, if you add two 8-bit numbers and the result requires a 9th bit, the 9th bit is typically discarded, leading to an incorrect result.

Signed Integers and Shifts

So far we've only dealt with positive numbers. To represent negative numbers in binary, computers often use a method called . In an 8-bit two's complement system, the most significant bit (the leftmost bit) indicates the sign. A '0' means the number is positive, and a '1' means it's negative. This system makes arithmetic with negative numbers much simpler for the processor's circuitry.

DenaryTwo's Complement (8-bit)
300000011
-311111101
12701111111
-12810000000

Finally, processors can perform a very fast type of multiplication and division using logical binary shifts. A logical left shift moves every bit one position to the left, and a 0 is added to the rightmost position. This is equivalent to multiplying the number by 2. Shifting left twice multiplies by 4, and so on.

A logical right shift moves every bit one position to the right, and a 0 is added to the leftmost position. This is equivalent to performing an integer division by 2.

Quiz Questions 1/6

Why is the hexadecimal number system frequently used in computing?

Quiz Questions 2/6

What is the denary (base-10) equivalent of the hexadecimal number 2B?