1.Lesson overview
- 1.1 Data Representation
- 5.1 Number bases
- 5.2 Units of information
- 5.3 The binary number system
- 2.1 Binary Numbers
- Distinguish decimal and binary prefixes in storage calculations.
- Convert positive integers between denary, binary and hexadecimal.
- Represent values using BCD, one's complement and two's complement.
- Add and subtract fixed-width two's-complement values.
- Multiply unsigned binary integers using the shift-and-add method and state the width the exact product needs.
- Identify and explain signed binary overflow.
- Justify the use of BCD and hexadecimal in practical applications.
- 1Name the quantity
Identify the unit, radix, signed convention and width.
- 2Convert the representation
Use place values, repeated division or four-bit hexadecimal groups.
- 3Operate at fixed width
Use complement methods and retain exactly the stated number of bits.
- 4Interpret the result
Check validity, range, overflow and the practical requirement.
2.Why computers use binary: bits, bytes and magnitude
Two states give a large tolerance to small changes in voltage, temperature and component behaviour.
Signals can be regenerated as they pass through logic gates, so a slightly weakened state can become a firm 0 or 1 again.
Arithmetic and logical circuits can be built from predictable combinations of two-state gates.
Unit or prefix | Meaning | Example |
|---|---|---|
bit | One binary digit | 0 or 1 |
byte | Eight bits | 1 bits |
kilo, mega, giga, tera | Decimal powers of 1000 | 1 bytes |
kibi, mebi, gibi, tebi | Binary powers of 1024 | 1 bytes |
Do not silently replace kB with KiB, or Mb with MB. Copy the unit into the working before calculating.
3.The three number systems and place value
System | Base | Digits | Example for 45 |
|---|---|---|---|
Denary | 10 | 0 to 9 | 45 |
Binary | 2 | 0 and 1 | 101101 |
Hexadecimal | 16 | 0 to 9 and A to F | 2D |
Denary columns are powers of 10: 1000, 100, 10 and 1.
Binary columns are powers of 2: 128, 64, 32, 16, 8, 4, 2 and 1 for one byte.
Hexadecimal columns are powers of 16: 256, 16 and 1 for a three-digit value.
Hex | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
Denary | 10 | 11 | 12 | 13 | 14 | 15 |
4.Place value and width determine the interpretation
A bit pattern has no numeric meaning until its base, width and signedness are specified. In unsigned binary, positions have weights 1, 2, 4 and so on. In n-bit two's complement, the leading bit has weight , giving range through . Overflow occurs when the mathematical answer lies outside that range, even if a fixed-width adder produces a bit pattern. Hexadecimal groups four bits and is a compact notation, not a different stored value.
5.Converting denary and binary
Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
Binary digit | 1 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
- 1Use 128128
128 fits into 156. Write 1; .
- 2Check 6464
64 does not fit into 28. Write 0; remainder stays 28.
- 3Check 3232
32 does not fit into 28. Write 0; remainder stays 28.
- 4Use 1616
16 fits into 28. Write 1; .
- 5Use both8 and 4
12 − 8 = 4, then 4 − 4 = 0. Write 1 and 1.
- 6Finish the width2 and 1
Neither fits into zero. Write 0 and 0. The answer is 10011100.
- 145 divided by 2 gives quotient 22, remainder 1.
- 222 divided by 2 gives quotient 11, remainder 0.
- 311 divided by 2 gives quotient 5, remainder 1.
- 45 divided by 2 gives quotient 2, remainder 1.
- 52 divided by 2 gives quotient 1, remainder 0.
- 61 divided by 2 gives quotient 0, remainder 1.
- 7Read upward: 101101. Pad to a byte if required: 00101101.
6.Converting denary and hexadecimal
- 1First division
274 divided by 16 gives quotient 17 and remainder 2. The rightmost digit is 2.
- 2Divide the quotient
17 divided by 16 gives quotient 1 and remainder 1. The middle digit is 1.
- 3Read the final quotient
The remaining quotient is 1, so the leftmost digit is 1.
- 4Check
112 is 256 + 16 + 2 = 274, so the conversion is consistent.
7.Converting hexadecimal and binary
Hex | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
Binary | 0000 | 0001 | 0010 | 0011 | 0100 | 0101 | 0110 | 0111 |
Hex | 8 | 9 | A | B | C | D | E | F |
Binary | 1000 | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111 |
- 1Hex to binary
Replace each digit with four bits: D6 becomes 1101 0110.
- 2Binary to hex
Group from the right in fours: 11010110 becomes 1101 0110, then D6.
- 3Pad the left group
If the leftmost group is short, add zeroes on its left. 110101 becomes 0011 0101, so the answer is 35.
- 4Preserve every nibble
Do not remove zeroes inside a group. Each hex digit must still represent exactly four bits.
8.Binary Coded Decimal (BCD)
Representation | Bit pattern for 59 | How it is decoded |
|---|---|---|
Unsigned binary | 111011 | One positional number: 32 + 16 + 8 + 2 + 1. |
BCD | 0101 1001 | Two separate digits: 5 then 9. |
- 1Separate the digits
For 708, identify the decimal digits 7, 0 and 8. Do not convert 708 as one binary integer.
- 2Encode each digit
7 becomes 0111, 0 becomes 0000 and 8 becomes 1000.
- 3Join the nibbles
The BCD pattern is 0111 0000 1000.
- 4Check validity
Every four-bit group must be between 0000 and 1001.
9.One's complement, two's complement and signed range
Representation | Negative construction | Important consequence |
|---|---|---|
Unsigned | Negative values are not represented. | Range is 0 to 2ⁿ − 1. |
One's complement | Invert every bit of the positive magnitude. | There are two encodings of zero. |
Two's complement | Invert every bit, then add 1. | There is one zero; range is −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1. |
10.Constructing and checking two's-complement values
- 1Choose the width
Use the width stated in the question. For eight bits, the valid signed range is −128 to +127.
- 2Write the magnitude
Write the positive magnitude in the same width. For 37: 00100101.
- 3Invert every bit
Change 0 to 1 and 1 to 0: 11011010.
- 4Add one
Add one at the least-significant end: 11011011.
- 5Verify
Use signed weights: −128 + 64 + 16 + 8 + 2 + 1 = −37.
Denary | Pattern | Reason |
|---|---|---|
+127 | 01111111 | Largest value with a leading sign bit of 0. |
0 | 00000000 | The one zero representation. |
−1 | 11111111 | −128 + 127 = −1. |
−128 | 10000000 | The negative leading weight with the other bits zero. |
Invert all the stated bits, add one within the stated width, and retain the width before interpreting the result. Leading zeroes are part of the working.
11.Binary addition, subtraction and multiplication at fixed width
Bits and carry | Write | Carry |
|---|---|---|
0 + 0 | 0 | 0 |
0 + 1 or 1 + 0 | 1 | 0 |
1 + 1 | 0 | 1 |
1 + 1 + 1 | 1 | 1 |
- 1Bit 0 of the multiplier
011 has a 1 in bit 0, so the first partial product is 101 shifted zero places: 00101.
- 2Bit 1 of the multiplier
011 has a 1 in bit 1, so the second partial product is 101 shifted one place left: 01010.
- 3Bit 2 of the multiplier
011 has a 0 in bit 2, so the third partial product is all zeroes and contributes nothing: 00000.
- 4Add the partial products
00101 + 01010 + 00000 = 01111.
- 5Check
5 × 3 = 15, and 01111₂ is 8 + 4 + 2 + 1 = 15, so the result is confirmed.
The exact product of two n-bit unsigned values can need up to 2n bits, not n bits. Multiplying two 4-bit values can need an 8-bit result, so state or reserve the width the answer requires rather than reusing the operand width automatically.
12.Signed overflow and range failure
Operands | Retained sign | Conclusion |
|---|---|---|
Positive + positive | 1, so result appears negative | Signed overflow |
Negative + negative | 0, so result appears positive | Signed overflow |
One positive and one negative | Either sign | No signed overflow from the addition |
13.Worked example 1: conversions, units and BCD
A sensor sends the unsigned binary value 10101101.
(a) Convert it to denary.
(b) Convert it to hexadecimal.
(c) Encode the denary value 45 in BCD.
(d) A file is labelled 2 KiB. How many bytes and how many bits is this?
- 1Part (a): binary to denary
Use the place values: 128 + 32 + 8 + 4 + 1 = 173. Therefore 10101101 is 173 in denary.
- 2Part (b): binary to hex
Group from the right: 1010 1101. The nibbles are A and D, so the hexadecimal value is AD.
- 3Part (c): BCD
Encode each decimal digit separately: 4 is 0100 and 5 is 0101. The BCD result is 0100 0101.
- 4Part (d): units
2 × 1024 = 2048 bytes. Each byte has 8 bits, so 2048 × 8 = 16384 bits.
Marking note. Part (a) needs place-value working, part (b) needs correct four-bit grouping, part (c) needs separate nibbles for 4 and 5, and part (d) needs the binary prefix before the byte-to-bit conversion. Writing 101101 for part (c) would be ordinary binary, not BCD.
14.Worked example 2: two's-complement subtraction
Use 8-bit two's-complement arithmetic to calculate 18 − 7. Show the representation of −7, the addition and the denary check.
- 1Write both magnitudes
18 is 00010010 and 7 is 00000111 in eight bits.
- 2Construct −7
Invert 00000111 to get 11111000; add 1 to get 11111001.
- 3Add the complement
00010010 + 11111001 = 1 00001011. Discard the carry beyond eight bits.
- 4Interpret the retained bits
The result is 00001011, which is 8 + 2 + 1 = 11. Therefore 18 − 7 = 11.
Marking note. The carry outside the register is discarded only after the eight-bit addition has been shown. If the width is omitted, the reader cannot tell whether the complement and the discarded carry were handled correctly.
15.Worked example 3: identify signed overflow
An 8-bit processor adds 01100100 and 00111100 as two's-complement integers. State the retained pattern and decide whether signed overflow occurs.
- 1Interpret the operands
Both sign bits are 0, so the operands are positive: 100 and 60.
- 2Add at fixed width
01100100 + 00111100 = 10100000. Only the eight retained bits are stored.
- 3Check the true total
The mathematical total is 160, but the 8-bit signed range ends at 127.
- 4State the conclusion
Overflow occurs. Two positive operands have produced a result with sign bit 1, which is interpreted as negative.
Marking note. Compare the mathematical total with the range as well as comparing signs. The retained pattern 10100000 is a stored bit pattern, not a correct representation of +160 in eight-bit two's complement.
16.Extended worked example: reason through the method
Add 0111 and 0011 as 4-bit two's-complement values. Interpret the result.
- 1
Both operands are positive: 0111 is 7 and 0011 is 3. Their mathematical sum is 10.
- 2
The 4-bit adder yields 1010, which represents -6 in two's complement.
- 3
The permitted range is -8 to +7, so this is signed overflow; 1010 is not the correct signed result.
Two positive inputs producing a negative sign bit is a quick overflow indicator. A wider 5-bit result would represent +10 correctly.
17.Choosing a representation for a real system
Requirement | Suitable choice | Reasoned justification |
|---|---|---|
Perform signed integer arithmetic in an ALU | Two's complement | It represents positive and negative values in a fixed width and lets the same adder support addition and subtraction. |
Drive a decimal clock or calculator display | BCD | Each four-bit group corresponds to one decimal digit, so the display interface can decode digits directly. It uses more bits for many values. |
Show a memory value to a technician | Hexadecimal | It is shorter and easier to read than binary, while each digit preserves an exact four-bit group. |
- 1Receive the readingInput
The sensor interface declares the bit width and signed convention so the controller can decode the reading consistently.
- 2Calculate internallyCompute
The processor uses two's complement for signed arithmetic, then checks the allowed range before accepting the result.
- 3Show decimal digitsDisplay
The display interface can use BCD when it expects one decimal digit per nibble.
- 4Report the patternDebug
The diagnostic output can use hexadecimal so an engineer can inspect the exact stored bits compactly.
18.Exam tips and common misconceptions
- 1
Underline the target: denary, binary, hexadecimal, BCD, one's complement or two's complement.
- 2
Write down the width. Keep leading zeroes and discard a carry only when the fixed-width operation is complete.
- 3
Label units explicitly: bits, bytes, kB, KiB, MB, MiB or another stated unit.
- 4
For hexadecimal conversion, group binary from the right and use exactly four bits per digit.
- 5
For BCD, separate the decimal digits before encoding. For overflow, state operand signs, retained sign and allowed range.
- 6
For a justification, connect the representation to the system requirement and include a consequence or trade-off.
Incorrect idea | Accurate correction |
|---|---|
“A kilobyte is always 1024 bytes.” | 1 kB is 1000 bytes; 1 KiB is 1024 bytes. Use the prefix in the question. |
“Hexadecimal is another form of BCD.” | Hexadecimal treats the whole value as base 16; BCD encodes each decimal digit separately. |
“The leading bit is just a sign flag.” | In two's complement it has negative place value and participates in the numerical result. |
“A carry out always means signed overflow.” | Signed overflow depends on operand and result signs. A carry out is mainly an unsigned-range clue. |
“The stored hex value uses fewer bits.” | Hex is compact notation for people; the underlying bit pattern is unchanged. |
“Invert bits to make two's complement.” | Invert every bit and then add one, all within the specified width. |
State or give usually requires a precise result. Describe requires the relevant features or steps. Explain requires a cause, mechanism or consequence. Justify requires a reason tied to the stated situation, often including a trade-off.
19.Synoptic worked example: from specification to bit pattern
A lift controller stores a signed floor offset in an 8-bit register, sends diagnostic values to an engineer, and drives a two-digit decimal display. Explain a suitable representation for each use. Then represent the offset −6 in the processor.
- 1Processor arithmetic
Use 8-bit two's complement because the offset may be negative and the processor needs fixed-width signed addition and subtraction.
- 2Engineer diagnostics
Use hexadecimal for the displayed bit pattern because it is compact, easier for a person to compare and maps directly to four-bit groups.
- 3Decimal display
Use BCD when the display interface expects separate decimal digits. It is convenient for digit decoding but not as storage-efficient as ordinary binary.
- 4Encode −6
+6 is 00000110; invert to 11111001; add one to get 11111010. Check: −128 + 64 + 32 + 16 + 8 + 2 = −6.
Why this scores well: every representation is tied to a requirement, and the numerical answer shows the width, construction method and verification. A list of three names without consequences would not be a justification.
20.Summary and self-check
Binary uses two reliable states. A bit is one binary digit and a byte is eight bits.
Decimal prefixes use powers of 1000; binary prefixes use powers of 1024. Bits and bytes are different units.
Binary uses powers of 2, denary uses powers of 10 and hexadecimal uses powers of 16.
Hexadecimal is compact human-readable notation because each digit maps to four binary bits.
BCD encodes each decimal digit separately. Its direct digit handling is useful, but it may use more bits.
One's complement inverts bits and has two zeroes. Two's complement inverts and adds one, giving one zero and a range of −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1.
Two's-complement subtraction adds the complement of the subtrahend and retains the selected width.
Unsigned binary multiplication uses shift-and-add: each multiplier bit selects the multiplicand or zero as a partial product, shifted into place and then summed. The exact product of two n-bit values can need up to 2n bits.
Signed overflow occurs when the mathematical result is outside the signed range. A carry out alone does not prove signed overflow.
- 1
Why are two-state digital components more reliable than a component that must distinguish ten voltage levels?
- 2
Convert 11101010 to denary and hexadecimal. Show the place values and nibble groups.
- 3
Write denary 204 as an 8-bit unsigned binary value, then state its hexadecimal form.
- 4
Encode denary 708 in BCD. Why is the result not the same as converting 708 as one binary integer?
- 5
State the 8-bit two's-complement range and explain why 10000000 represents −128 rather than −0.
- 6
Use 8-bit two's complement to calculate 25 − 9. Show the complement and the retained result.
- 7
Multiply 110₂ (6) by 101₂ (5) using shift-and-add. Show every partial product and state how many bits the exact result needs.
- 8
Does 01111111 + 00000001 overflow as signed addition? State the operand values, retained pattern and reason.
- 9
A user needs exact decimal digits, a technician needs a compact view of memory, and an ALU needs signed arithmetic. Which representation fits each requirement, and why?
21.Detailed revision focus — representation, width and signed overflow
This lesson is about representation, width and signed overflow. In a strong answer, name the relevant representation or mechanism, apply it to the stated evidence, then give a conclusion that fits the conditions of the question.
Distinguish decimal and binary prefixes in storage calculations.
Convert positive integers between denary, binary and hexadecimal.
Represent values using BCD, one's complement and two's complement.
22.Worked Example 3 — representation, width and signed overflow
Using 8-bit two's complement, calculate 00110101 + 11011011 and state whether overflow has occurred.
- 1Interpret the first pattern as +53.
- 2Interpret the second pattern as −37 because its leading bit is 1; equivalently, invert it and add 1 to find its magnitude.
- 3Add at the stated 8-bit width:
00110101 + 11011011 = 1 00010000. - 4Discard the ninth carry and check whether two numbers of the same sign produced an answer with a different sign.
00010000, which is +16. There is no signed overflow because the addends have different signs.
23.High-value distinction — A carry out and signed overflow
| Term | Meaning | Why the distinction matters |
|---|---|---|
| A carry out | a bit leaving the fixed width during addition | Use A carry out only for its specific role; it is not interchangeable with signed overflow. |
| signed overflow | a result outside the signed range; it is detected from the signs of the operands and result, not merely from a carry | Use signed overflow when this is the mechanism, condition or property the question actually describes. |
When comparing these ideas, state one difference in purpose or mechanism before giving an example. A pair of definitions with no comparison does not fully answer a “compare” question.
24.Mark-ready route — representation, width and signed overflow
- 1Identify the rule or representationStep 1
Interpret the first pattern as +53.
- 2Apply it to the evidenceStep 2
Interpret the second pattern as −37 because its leading bit is 1; equivalently, invert it and add 1 to find its magnitude.
- 3Keep the condition visibleStep 3
Add at the stated 8-bit width:
00110101 + 11011011 = 1 00010000. - 4Check the conclusionStep 4
Discard the ninth carry and check whether two numbers of the same sign produced an answer with a different sign.
Before finalising, check the command word, any stated width, unit, order or condition, and whether your conclusion answers the exact scenario rather than a similar one.
25.Targeted correction and transfer — representation, width and signed overflow
Calling every carry overflow. Mixed-sign addition can produce a carry without signed overflow.
New situation: A register stores an 8-bit signed temperature. Explain why 01111111 + 00000001 is invalid even though the output bit pattern is a legal 8-bit pattern.
Without notes, explain the difference between A carry out and signed overflow, then outline the method from the worked example in four or fewer steps.