Computers store and process information using binary (base 2), where every digit is either 0 or 1, corresponding to the two voltage states of electronic circuits. Humans write numbers in decimal (base 10) - ten digits, 0 through 9 - and each position represents a power of ten. Hexadecimal (base 16) uses sixteen symbols (0–9 and A–F) and is commonly used in computing because one hex digit maps exactly to four binary digits (bits), making large binary values far more readable.
Converting between bases relies on place value. In binary, the rightmost digit has value 2⁰ = 1, the next 2¹ = 2, then 2² = 4, and so on. The decimal number 42 is 00101010₂ in binary (32+8+2) and 2A₁₆ in hex.
To convert decimal to binary, repeatedly divide by 2 and record the remainders in reverse. Hex is especially useful for representing memory addresses, RGB colors, and machine-level instructions where bit-level manipulation is important.
Understanding Binary, Decimal, Hexadecimal
A number system is a way of giving a value to each position in a written number. The important idea is that a digit has a different value depending on where it sits. In decimal, the digits in 352 represent three hundreds, five tens, and two ones.
The same pattern works in every base, but the size of each place changes. This is why a binary value that looks long may represent an ordinary decimal number.
Students should practise expanding numbers into place values before using any shortcut. It makes conversion methods easier to check and helps prevent guessing.
The repeated division method works because every whole number can be split into groups of two. Each remainder tells whether a particular power of two is included. Reading the remainders from bottom to top matters because the first remainder belongs to the ones place, while later remainders belong to larger places.
For a reverse conversion, add the values of the positions containing one. A useful checking habit is to convert the result back to decimal.
If both routes give the same value, the working is probably correct. Errors often come from skipping a place value or reading digits in the wrong direction.
Hexadecimal is mainly a compact writing system for binary data. A group of four bits has sixteen possible patterns, so it can be replaced by one hex symbol. The letters A through F stand for values after nine, not for separate variables or grades.
Grouping must begin at the rightmost end because that is where the smallest place value is. Extra zero bits can be added on the left to complete a group of four without changing the value.
These leading zeros matter when showing fixed size data, such as an eight bit value. They show the stored pattern even when they do not change the numerical amount.
Students meet hexadecimal in colour codes used on websites and graphics software. A six digit colour code contains three pairs of hex digits. The pairs describe the strength of red, green, and blue light.
Hex values are common in error messages, memory locations, file data, and network tools because they let people inspect bit patterns without reading long strings of zeros and ones. Number bases matter beyond conversion exercises. They connect directly to data size, permissions, colours, text encoding, and processor instructions.
Computer values have limits because memory uses a fixed number of bits. With eight bits, there are two hundred and fifty six possible patterns. If a program tries to store a larger unsigned value in only eight bits, some information cannot fit.
This is called overflow. Negative values need an agreed binary encoding, commonly two's complement, so their patterns follow different rules from simple positive numbers.
When learning this topic, keep the type and bit width visible. A binary pattern by itself does not always reveal whether it represents a positive number, a negative number, a colour component, or part of an instruction.
Key Facts
- Binary (base 2): digits 0 and 1; each position is a power of 2
- Decimal (base 10): digits 0–9; each position is a power of 10
- Hexadecimal (base 16): digits 0–9, A–F; each position is a power of 16
- 1 hex digit = 4 binary bits; 2 hex digits = 1 byte (8 bits)
- Decimal to binary: divide by 2, record remainders in reverse
- Binary to hex: group bits in sets of 4 from the right, convert each group
Vocabulary
- Bit
- The smallest unit of digital information; a single binary digit, either 0 or 1.
- Byte
- A group of 8 bits; can represent 256 different values (0–255 in decimal, 00–FF in hex).
- Place value
- The value of a digit determined by its position in the number; each position represents a power of the base.
- Base (radix)
- The number of unique digits a positional numeral system uses; binary is base 2, decimal is base 10, hex is base 16.
- Hexadecimal
- A base-16 number system using digits 0–9 and letters A–F; widely used in computing to represent binary data compactly.
Common Mistakes to Avoid
- Confusing hex letters with decimal values. In hex, A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. FF in hex is 255 in decimal, not 11.
- Forgetting to group binary digits from the right when converting to hex. Starting from the left can create unequal groups. Always pad with leading zeros so the total number of bits is a multiple of 4.
- Treating 0x prefix as part of the value. '0x' (or '0b' for binary) is a notation prefix indicating the base - the prefix itself has no numeric value.
- Assuming hex numbers are always larger than decimal numbers with the same digits. The value depends on the base: 10 in hex equals 16 in decimal, not 10.
Practice Questions
- 1 Convert the decimal number 173 to binary and to hexadecimal. Show your work.
- 2 The hexadecimal color code for a web page element is #3A7F. Convert each pair of hex digits to decimal to find the RGB values.
- 3 Why do computers use binary internally rather than decimal? Explain the connection to the physical properties of electronic components.