Number representation and arithmetic
Separate the stored bit pattern from the numerical interpretation. First identify radix, word length, sign format and binary-point position. Arithmetic overflow and lost precision are different errors.
3.1 Radix and complements
Past papers · CS 2014–2026 (23 papers): 10 questions, 13 marks · EC 2020–2026 (7 papers): 3 questions, 4 marks
Convert integer parts by repeated division and fractional parts by repeated multiplication. Group binary digits in threes for octal and fours for hexadecimal, starting at the radix point and padding only at the outer ends. In an unknown-base equation every digit must be smaller than the base; a polynomial root that violates this is invalid.
For subtraction with radix complement, add the complement and discard an end carry; without a carry, the result is negative and its magnitude is the complement of the stored result. Diminished-radix-complement arithmetic uses end-around carry. The latter has two zero encodings.
3.2 Signed integers and overflow
Past papers · CS 2014–2026 (23 papers): 9 questions, 9 marks · EC 2020–2026 (7 papers): 1 question, 2 marks
Let be the sign bit and the unsigned interpretation. Leading zeros do not affect unsigned value; negative two's-complement numbers require sign extension when widening.
Two's-complement negation in bits is bitwise inversion plus one, modulo . The most negative value cannot be negated within the same signed width. For sign magnitude, perform magnitude addition for equal signs and magnitude subtraction for opposite signs; determine overflow from the mathematical result and range. Do not use the two's-complement carry test on sign-magnitude addition.
3.3 Fixed-point scaling
Past papers · CS 2014–2026 (23 papers): 2 questions, 3 marks
State the total width and fractional-bit count instead of relying on an ambiguous Q-format name. Here includes the sign bit and is the number of fractional bits.
Align binary points before addition. For multiplication, an exact full-width product of widths has width and fractional bits. Rescale before storing into the destination format. Arithmetic right shift replicates the sign bit and rounds negative integers towards minus infinity; logical right shift inserts zeros. Left shift multiplies by a power of two only when the result fits.
3.4 Floating-point fields
Past papers · CS 2014–2026 (23 papers): 6 questions, 7 marks
Write the sign bit , stored exponent and fraction integer separately. If the fraction contains bits, its value is ; the hidden leading bit is not stored.
A normal number has significant binary digits. NaN is not a very large number and cannot be ranked as one. Positive normal encodings increase with numerical value; negative values require reversed magnitude ordering. Signed zero compares equal numerically despite its sign bit. Format reference.
3.5 Floating-point arithmetic and rounding
Past papers · CS 2014–2026 (23 papers): 5 questions, 10 marks
For addition, decode both exponents, right-shift the smaller significand to align exponents, add or subtract according to signs, normalise, then round. A carry can require a right shift and exponent increment; cancellation can require several left shifts. For multiplication, XOR the signs, add unbiased exponents, multiply significands, normalise and round. For division, subtract unbiased exponents and divide significands.
Under round-to-nearest, ties-to-even, use guard , round and sticky bits beyond the retained significand. Increment it when and at least one of or the retained LSB is 1. Sticky is the OR of all lower discarded bits. Other modes are towards zero, towards positive infinity and towards negative infinity. Rounding can itself overflow the significand and increment the exponent. Floating-point addition is not associative.
Last-minute recall
- Every digit must be smaller than its radix.
- Two's-complement widening copies the sign bit.
- Carry and signed overflow answer different questions.
- Fixed-point multiplication adds fractional-bit counts.
- Exponent zero means a hidden leading zero, not one.
- An all-ones exponent is reserved for infinity and NaN.
- Align exponents before floating-point addition.
- Retain guard, round and sticky information until final rounding.