A bit pattern does not carry its own interpretation. The same eight bits can represent an unsigned value, a signed integer, a character code or flags.
Content owner: Michael Print · Written for A-Level learners · Checked against official specifications
The idea to start with
Write the bit width and interpretation first. Unsigned n-bit integers range from zero to 2^n−1. Two's-complement n-bit integers range from −2^(n−1) to 2^(n−1)−1. Use those ranges to check whether an arithmetic result can be represented.
Hexadecimal is a compact notation for binary: one hex digit represents four bits. It does not add capacity to the underlying representation. Shifts move bit positions, while masks select, set or toggle individual bits.
OCR H446 · 1.4.1(a–f,i). Real-number representation and character sets continue in the companion guide.
Before you start
Useful foundations
Powers of two
Denary arithmetic
AND, OR and XOR truth rules
By the end, you should be able to
Convert positive integers between bases
Encode negative integers using sign/magnitude and two's complement
Calculate fixed-width sums and differences and detect overflow
Explain logical shifts and bit masks
Choose a primitive type before choosing bits
Choose a type using the data’s meaning. A postcode belongs in a string even when it looks numeric; a count needs an integer and a measured temperature may need a real type.
Language implementations differ. Python has strings but no separate built-in character type, and its integers can grow beyond one byte. Our arithmetic deliberately uses fixed eight-bit registers, so a Python model must impose those limits.
Match a primitive type to its meaning
Integer→
Whole numbers, such as a count.
Real / floating point→
Approximations to real values, such as a fractional temperature.
Character→
One character value, such as a mode letter.
String→
A sequence of characters, such as a postcode.
Boolean→
A true/false state, such as a fault flag.
Convert bases by place value and groups of four
Unsigned eight-bit weights are 128,64,32,16,8,4,2,1. For 10011001, add 128+16+8+1=153. Group as 1001 1001: each nibble is nine, giving hex 99.
Hex A–F mean denary 10–15. For example, 2D is 2×16+13=45 and becomes binary 0010 1101.
Convert denary to binary by choosing place values, or repeatedly dividing by two and reading remainders in reverse. Divide by sixteen for hex. Preserve the stated width: left-hand zero padding does not change a positive unsigned value.
Negative values need a representation rule
Eight-bit sign and magnitude uses one sign bit and seven magnitude bits. −23 is 10010111: sign 1 and magnitude 0010111=23. The range is −127…+127, with positive and negative zero.
Eight-bit two’s complement uses weights −128,64,32,16,8,4,2,1. It has one zero and range −128…+127. Addition uses ordinary bit-column addition, followed by interpretation and an overflow check.
Encode −23 in eight-bit two’s complement
1
Start with +23
00010111.
2
Invert every bit
11101000.
3
Add one
11101001.
4
Check the signed weights
−128+64+32+8+1=−23.
Carry and signed overflow answer different questions
Add right to left, carrying when a column reaches two. Subtract B by adding its negation in two’s complement. Retain only the stated width; an outgoing carry identifies unsigned overflow, not every signed overflow.
Signed overflow occurs when two same-sign operands produce an opposite-sign result. For eight-bit 100+60, the stored pattern is 10100000.
Unsigned interpretation gives 160, which fits. Signed interpretation gives −96, because the true sum exceeds −128…127. Always compare the mathematical result with the chosen range.
Logical shifts and masks
Logical shifts insert zeroes. 00110110 (54) shifted left once is 01101100 (108); shifted right once is 00011011 (27). Left shifting multiplies by two only if no needed bit is lost and the result still fits.
Right logical shifting is not general signed division: signed 11111011 (−5) becomes 01111101 (+125). An arithmetic right shift instead copies the sign bit.
A mask acts on selected bit positions. Match each mask bit to the required action; masking is not arithmetic subtraction.
Three mask operations on `10110110`
AND keeps selected bits
10110110 AND 00001111 = 00000110. Keep only the lowest four bits.
OR sets selected bits
10110110 OR 01000000 = 11110110. Set that bit without clearing others.
XOR toggles selected bits
10110110 XOR 00100000 = 10010110. Reverse the selected bit.
Worked example
Choose types for a fictional monitoring record
Use an integer for a whole count of samples and a real/floating-point value for a temperature that may include a fractional part. Their supported ranges and precision still need specifying.
Use a string for a sensor identifier such as 007A, preserving the leading zero. Use a conceptual character for a single mode letter such as H, and a Boolean for a fault-present true/false state. These choices describe the data's meaning rather than guessing from its appearance.
Worked example
Calculate 7−12 using eight-bit two's complement
Encode +7 as 00000111 and +12 as 00001100. Negate 12: invert to 11110011, add one to get 11110100.
Add 00000111 + 11110100 = 11111011. Decode using the signed weights: −128+64+32+16+8+2+1=−5. The operands have opposite signs, so this addition cannot overflow the signed range.
As another check, +45 (00101101) plus +31 (00011111) gives 01001100=76. Both the sign and numerical range agree with the mathematical result.
Representation determines the meaning
Eight-bit pattern
Unsigned
Two's complement
00000111
7
7
11110100
244
-12
11111011
251
-5
10100000
160
-96
Original A-Level practice
6 original questions total 20 marks. Attempt each before opening the independently written indicative marking guidance.
Question 1
3 marks
Convert hexadecimal B6 to eight-bit binary and denary, showing the place-value calculation. [3 marks]
Show solution and marking guidance+
Indicative answer
B=1011 and 6=0110, giving 10110110 (1). B is denary eleven (1); 11×16+6=182 (1).
Question 2
4 marks
Represent −19 in eight-bit sign/magnitude and two's complement. [4 marks]
Show solution and marking guidance+
Indicative answer
Magnitude 19 is 0010011 (1), so sign/magnitude is 10010011 (1). +19 is 00010011; inverting gives 11101100 (1), and adding one gives 11101101 (1).
Question 3
3 marks
For eight-bit two's-complement integers, add 01100100 and 00111100. Identify overflow and explain it. [3 marks]
Show solution and marking guidance+
Indicative answer
The bit sum is 10100000 (1). Signed overflow occurred (1): two positive inputs produced a negative signed pattern, and 100+60=160 exceeds +127 (1).
Question 4
3 marks
Apply AND 00001111, OR 01000000 and XOR 00100000 separately to the original flags 10110110. [3 marks]
Show solution and marking guidance+
Indicative answer
AND: 00000110 (1). OR: 11110110 (1). XOR: 10010110 (1). Each operation starts from the original flags.
Question 5
2 marks
Explain why an eight-bit logical left shift of unsigned 10000001 does not correctly store its value multiplied by two. [2 marks]
Show solution and marking guidance+
Indicative answer
The leading one is discarded, leaving 00000010=2 (1). The true result is 129×2=258, outside the eight-bit unsigned range 0…255 (1).
Question 6
5 marks
Choose conceptual primitive types for a parcel count, measured mass with fractional grams, one category letter, a postcode and a delivered/not-delivered flag. [5 marks]
Show solution and marking guidance+
Indicative answer
Integer for the whole count (1); real/floating-point for the fractional measurement (1); character for the single category letter (1); string for the postcode (1); Boolean for the two-state flag (1). A language without a distinct character type can store that character in a one-character string, while retaining the conceptual distinction.
Specification and references
This guide addresses OCR H446 1.4.1(a–f,i). Real-number representation and character sets continue in the companion guide.. Check your examination year and the complete specification for the assessment scope.
These are independently written explanations and practice questions. CompSciTutoring.co.uk is not affiliated with or endorsed by an examination board. The marking guidance is indicative; always check the syllabus for your examination year.