[1.1.2(a)] Denary/binary/hex systems

Understanding Number Systems

Every day, you use numbers to count, calculate, and communicate quantities. When you write "365" to represent the number of days in a year, you are using the denary system (also called decimal or base-10), which is the number system humans have used for thousands of years. However, computers work with numbers differently, primarily using binary (base-2) and hexadecimal (base-16) systems. Understanding these three number systems and how they relate to each other is fundamental to computer science.

The Denary System (Base-10)

How Denary Works

The denary system (base-10) is the number system you use every day. It is called "base-10" because it uses ten different digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. When counting in denary, once you reach 9, you move to the next position and start again with 0, creating 10.

Denary uses a positional notation system, which means the position of each digit determines its value. Each position represents a power of 10, starting from the rightmost position. The rightmost position represents 100 (which equals 1), the next position to the left represents 101 (which equals 10), then 102 (which equals 100), and so on.

For example, the denary number 5,247 breaks down as follows: (5 × 103) + (2 × 102) + (4 × 101) + (7 × 100) = (5 × 1000) + (2 × 100) + (4 × 10) + (7 × 1) = 5000 + 200 + 40 + 7 = 5,247. Each digit is multiplied by the power of 10 corresponding to its position, and all these values are added together to give the final number.

Why Humans Use Base-10

The denary system likely developed because humans have ten fingers, making it natural to count in groups of ten. This system has been used for thousands of years across many cultures and has become the standard for everyday mathematics, commerce, and communication. Its familiarity makes it the reference point when learning about other number systems.

The Binary System (Base-2)

How Binary Works

The binary system (base-2) uses only two digits: 0 and 1. It is called "base-2" because there are only two possible digit values. When counting in binary, once you reach 1, you must move to the next position and start again with 0, creating 10 (which represents 2 in denary).

Binary also uses positional notation, but each position represents a power of 2 instead of a power of 10. The rightmost position represents 20 (which equals 1), the next position represents 21 (which equals 2), then 22 (which equals 4), 23 (which equals 8), and so on. Each position moving left doubles in value.

For example, the binary number 1011 breaks down as follows: (1 × 23) + (0 × 22) + (1 × 21) + (1 × 20) = (1 × 8) + (0 × 4) + (1 × 2) + (1 × 1) = 8 + 0 + 2 + 1 = 11 in denary. Each binary digit (called a bit) is multiplied by the power of 2 corresponding to its position.

Binary Place Values

Understanding the place values in binary is crucial for working with this number system. Here are the first eight binary positions from right to left:

Position (right to left) Power of 2 Denary Value
1st (rightmost) 20 1
2nd 21 2
3rd 22 4
4th 23 8
5th 24 16
6th 25 32
7th 26 64
8th 27 128

An 8-bit binary number can represent values from 00000000 (0 in denary) to 11111111 (255 in denary), giving 256 different possible values. This pattern of doubling place values (1, 2, 4, 8, 16, 32, 64, 128...) is essential to remember when working with binary numbers.

Why Computers Use Binary

Computers use binary because their electronic circuits work with two stable states: on (representing 1) and off (representing 0). This two-state system is simple, reliable, and resistant to errors, making binary the natural choice for digital electronics. All data in a computer - numbers, text, images, sound - is ultimately stored and processed as patterns of binary digits.

The Hexadecimal System (Base-16)

How Hexadecimal Works

The hexadecimal system (base-16), often abbreviated as "hex", uses sixteen different digits. Since our standard number symbols only go from 0 to 9 (ten symbols), hexadecimal extends this by using the letters A, B, C, D, E, and F to represent the values 10 through 15. The complete set of hexadecimal digits is: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

In hexadecimal: A represents 10 in denary, B represents 11, C represents 12, D represents 13, E represents 14, and F represents 15. When counting in hexadecimal, after reaching F (15), you move to the next position and start again with 0, creating 10 (which represents 16 in denary).

Hexadecimal Place Values

Like denary and binary, hexadecimal uses positional notation. Each position represents a power of 16. The rightmost position represents 160 (which equals 1), the next position represents 161 (which equals 16), then 162 (which equals 256), then 163 (which equals 4096), and so on.

For example, the hexadecimal number 2A3 breaks down as follows: (2 × 162) + (A × 161) + (3 × 160) = (2 × 256) + (10 × 16) + (3 × 1) = 512 + 160 + 3 = 675 in denary. Remember that A represents 10, so we multiply 10 by 16 in the calculation.

Position (right to left) Power of 16 Denary Value
1st (rightmost) 160 1
2nd 161 16
3rd 162 256
4th 163 4096

Hexadecimal Digit Values

It is essential to memorise the relationship between hexadecimal digits and their denary equivalents, especially for the letters A through F:

Hexadecimal Digit Denary Value Binary Equivalent (4 bits)
000000
110001
220010
330011
440100
550101
660110
770111
881000
991001
A101010
B111011
C121100
D131101
E141110
F151111

Comparing the Three Number Systems

Representing the Same Values

All three number systems can represent the same quantities, but they do so using different notations. Here are some examples showing the same values in all three systems:

Denary Binary Hexadecimal
000000
501015
101010A
151111F
160001000010
31000111111F
1000110010064
25511111111FF

Key Characteristics

Each number system has distinct characteristics that make it suitable for different purposes:

Denary (Base-10): Uses 10 digits (0-9). Natural for human use due to our ten fingers. Standard for everyday mathematics, commerce, and communication. Easy to understand and work with for most people.

Binary (Base-2): Uses 2 digits (0, 1). Natural for computers due to two-state electronic circuits. Requires many digits to represent large numbers. Difficult for humans to read and work with directly, but essential for understanding how computers store and process data.

Hexadecimal (Base-16): Uses 16 digits (0-9, A-F). Serves as a bridge between binary and human-readable formats. Very compact compared to binary (one hex digit = four binary digits). Widely used in computing for memory addresses, colours, and machine code. Much easier for humans to work with than binary whilst maintaining a direct relationship with binary values.

Deep Dive: Place Value Systems Across Different Bases

Understanding how positional notation works across different bases reveals the elegant mathematical pattern underlying all these number systems. In any base-n system, each position represents a power of n, and you have n different digit symbols available (0 through n-1).

For base-10 (denary), you have digits 0-9, and positions represent powers of 10 (1, 10, 100, 1000...). For base-2 (binary), you have digits 0-1, and positions represent powers of 2 (1, 2, 4, 8, 16, 32...). For base-16 (hexadecimal), you have digits 0-F, and positions represent powers of 16 (1, 16, 256, 4096...).

This pattern extends to any base. For example, a hypothetical base-5 system would use digits 0-4, with positions representing powers of 5 (1, 5, 25, 125...). The number 342 in base-5 would equal (3 × 25) + (4 × 5) + (2 × 1) = 75 + 20 + 2 = 97 in denary.

The beauty of positional notation is that it allows any quantity to be represented in any base using the same fundamental principle. The choice of base is simply a matter of which is most convenient for the application - base-10 for humans, base-2 for computers, and base-16 as a practical compromise between human readability and computer compatibility.

Recognising these patterns helps when working with conversions between number systems. Each system follows the same rules: multiply each digit by the appropriate power of the base, then sum all the results. This consistent approach means that once you understand one system, the principles transfer directly to understanding any other base system.

Recognising Number Systems

When working with numbers in computing, it is important to identify which number system is being used. Several conventions help distinguish between systems:

  • Denary numbers: Written without special notation (e.g. 255). Context usually makes it clear these are denary
  • Binary numbers: Often written with a subscript 2 (e.g. 111111112) or with prefix 0b in programming (e.g. 0b11111111)
  • Hexadecimal numbers: Often written with a subscript 16 (e.g. FF16) or with prefix 0x in programming (e.g. 0xFF). Web colours use the hash symbol (e.g. #FF5733)

Additionally, context provides clues: if a number contains only 0s and 1s, it is likely binary; if it contains letters A-F, it must be hexadecimal; if it is being used for a memory address or colour code, it is probably hexadecimal. Developing the ability to quickly recognise which system is in use is an important skill in computer science.

 Key Takeaways

  • The denary (base-10) system uses ten digits (0-9) with each position representing a power of 10, making it natural for human use
  • The binary (base-2) system uses two digits (0 and 1) with each position representing a power of 2, making it natural for computer circuits
  • The hexadecimal (base-16) system uses sixteen digits (0-9 and A-F) with each position representing a power of 16, where A=10, B=11, C=12, D=13, E=14, and F=15
  • All three number systems use positional notation - the position of each digit determines its value based on powers of the base
  • Hexadecimal is particularly useful in computing because each hex digit represents exactly four binary digits, providing a compact and human-readable way to represent binary data
  • The same value can be represented in all three systems, just using different notations - for example, 255 (denary) = 11111111 (binary) = FF (hexadecimal)