Representation of Integers, Signed Integers, and Reals (incl. Double Precision)

At a Glance

Why This Chapter Matters

A single 5-mark question from 2024 covers the full spectrum of number representation — unsigned integers, signed integers (2’s complement), and IEEE 754 double-precision floating-point. The marks are quick if the double-precision bit layout is memorised and the bias-1023 formula is applied correctly. This atom is a reliable minimal-effort maximum-marks target.

Minimum Theory

Unsigned Integers

An nn-bit unsigned integer stores values from 00 to 2n−12^n - 1. The value is:

V=∑k=0n−1bk⋅2kV = \sum_{k=0}^{n-1} b_k \cdot 2^k

where bkb_k is the kk-th bit (LSB = b0b_0).

Signed Integers: Three Schemes

SchemePositive NNNegative −N-NRange (nn bits)
Sign-magnitude0 ∥N∥0\,\|N\|1 ∥N∥1\,\|N\|−(2n−1−1)-(2^{n-1}-1) to 2n−1−12^{n-1}-1; two zeros
1’s complementNNN‾\overline{N} (bitwise NOT)−(2n−1−1)-(2^{n-1}-1) to 2n−1−12^{n-1}-1; two zeros
2’s complementNNN‾+1\overline{N}+1−2n−1-2^{n-1} to 2n−1−12^{n-1}-1; one zero

2’s complement is universal in modern hardware. Its key advantage: ordinary binary addition works for both positive and negative numbers without special cases.

Detecting overflow in 2’s complement addition. Overflow occurs if and only if two numbers of the same sign are added and the result has the opposite sign.

Fixed-Point Reals (Q-format) — not the same thing as floating point

If a word is specified by giving the number of fractional bits, the binary point is nailed to one place and the format is fixed point, not floating point. There is no exponent field, no bias, and no implicit leading 11. An nn-bit word with ff fractional bits (a Q(n−f).fQ(n-f).f format) has value

val=∑i=−f n−f−1bi 2 i=bn−f−12n−f−1+⋯+b020⏟integer part+b−12−1+⋯+b−f2−f⏟fractional part.\text{val}=\sum_{i=-f}^{\,n-f-1} b_i\,2^{\,i} =\underbrace{b_{n-f-1}2^{n-f-1}+\cdots+b_02^0}_{\text{integer part}}+\underbrace{b_{-1}2^{-1}+\cdots+b_{-f}2^{-f}}_{\text{fractional part}}.

Fast equivalent: read all nn bits as one plain binary integer NN and divide by 2f2^f — inserting a binary point ff places from the right is a division by 2f2^f. Use it as a free arithmetic check on the positional sum.

val=N2f.\text{val}=\frac{N}{2^{f}}.

Exactness rule. Every QQ-format word is an exact multiple of 2−f2^{-f}, so its decimal value terminates in at most ff places. An answer with a recurring decimal tail is wrong by construction — a useful sanity check worth stating.

Sign. A bit-count and a point position do not by themselves determine a sign convention. Unless the question names a sign bit, read the word unsigned, and say that you are doing so. (The signed readings of an nn-bit word are N−2n−1N-2^{n-1} negated for sign-magnitude, and N−2nN-2^n for two’s complement, both then scaled by 2−f2^{-f}.)

Floating-Point: IEEE 754 Double Precision

Bit layout (64 bits total):

s⏟1  e10⋯e0⏟11  m51⋯m0⏟52\underbrace{s}_{1}\;\underbrace{e_{10}\cdots e_0}_{11}\;\underbrace{m_{51}\cdots m_0}_{52}

Value of a normalised number (1≤E≤20461 \le E \le 2046):

x=(−1)s×1.m×2E−1023x = (-1)^s \times 1.m \times 2^{E - 1023}

where 1.m1.m means 1+∑k=152mk⋅2−k1 + \sum_{k=1}^{52} m_k \cdot 2^{-k}.

Special values:

EE (stored)mmMeaning
00±0\pm 0
0≠0\ne 0Subnormal: (−1)s×0.m×2−1022(-1)^s \times 0.m \times 2^{-1022}
20470±∞\pm \infty
2047≠0\ne 0NaN

Machine epsilon. The smallest ε\varepsilon such that 1+ε≠11 + \varepsilon \ne 1 in double precision:

εmach=2−52≈2.22×10−16\varepsilon_{\text{mach}} = 2^{-52} \approx 2.22 \times 10^{-16}

Converting a decimal to double precision — procedure:

  1. Determine the sign bit ss.
  2. Convert ∣x∣|x| to binary.
  3. Normalise: write as 1.m×2e1.m \times 2^e (shift the binary point so that exactly one 1 is to the left).
  4. Biased exponent: E=e+1023E = e + 1023; convert EE to 11-bit binary.
  5. Mantissa: take the 52 bits after the binary point of 1.m1.m, padding with zeros on the right if needed.

Question Archetypes

ArchetypeRecognition
decimal-to-doubleRepresent a given decimal number in IEEE 754 double-precision format
interpret-bit-patternGiven a 64-bit pattern, decode the double-precision value
signed-range-or-2s-compState the range, or convert a negative number to 2’s complement
fixed-point-decodeA word is given “with ff bits as fractional part”; find its decimal value

decimal-to-double (1 question; 2024)

Recognition Cues

Solution Template

  1. Write s=0s = 0 (positive) or s=1s = 1 (negative).
  2. Convert ∣x∣|x| to binary using repeated multiplication (fractional part) or division (integer part).
  3. Normalise to 1.f×2e1.f \times 2^e.
  4. Compute biased exponent E=e+1023E = e + 1023; express as 11-bit binary.
  5. Write the 52 mantissa bits (the fractional part ff, padded to 52 bits).
  6. Assemble: s  ∣  E10⋯E0  ∣  m51⋯m0s\;|\;E_{10}\cdots E_0\;|\;m_{51}\cdots m_0.

Worked Example

2024 Paper 2, 2024-P2-Q8a (5 marks)

Represent the decimal number −13.625-13.625 in IEEE 754 double-precision (64-bit) floating-point format. Give the sign bit, biased exponent (in binary), and the first 10 bits of the mantissa.

Step 1 — sign bit.

x=−13.625<0x = -13.625 < 0, so s=1s = 1.

Step 2 — convert ∣x∣=13.625|x| = 13.625 to binary.

Integer part: 13=8+4+1=1101213 = 8+4+1 = 1101_2.

Fractional part: 0.625×2=1.25→0.625 \times 2 = 1.25 \to bit 1; 0.25×2=0.5→0.25 \times 2 = 0.5 \to bit 0; 0.5×2=1.0→0.5 \times 2 = 1.0 \to bit 1. Stop.

So 0.62510=0.10120.625_{10} = 0.101_2.

Therefore: 13.62510=1101.101213.625_{10} = 1101.101_2.

Step 3 — normalise.

1101.1012=1.101101×231101.101_2 = 1.101101 \times 2^3

Exponent e=3e = 3.

Step 4 — biased exponent.

E=3+1023=102610E = 3 + 1023 = 1026_{10}

Convert 10261026 to 11-bit binary:

1026=1024+2=210+21  ⟹  1000000001021026 = 1024 + 2 = 2^{10} + 2^1 \implies 10000000010_2

Step 5 — mantissa (52 bits).

The fractional part of 1.1011011.101101 is 10110100⋯0⏟46101101\underbrace{00\cdots0}_{46}. The first 10 mantissa bits are 10110100001011010000.

Step 6 — assemble.

1⏟s  10000000010⏟E,  11 bits  1011010000⋯0⏟m,  52 bits\underbrace{1}_{s}\;\underbrace{10000000010}_{E,\;11\text{ bits}}\;\underbrace{1011010000\cdots0}_{m,\;52\text{ bits}} s=1,E=100000000102,m=101101000000⋯0⏟42\boxed{s=1,\quad E = 10000000010_2,\quad m = 1011010000\underbrace{00\cdots0}_{42}}

Common Traps

fixed-point-decode (1 question(s); 2026)

Read the format specification, not the label. A question may call the word “floating point” and describe a fixed-point one. The give-away is that it tells you how many bits are fractional: that pins the binary point, which is precisely what floating point does not do. Solve it as fixed point — that is the only reading under which the given data determines an answer at all.

Recognition Cues

Solution Template

  1. Fix the format in one opening sentence — n−fn-f integer bits, then the point, then ff fractional bits, read unsigned. This sentence is what lets the examiner distinguish a correct answer from a lucky one.
  2. Split the string after n−fn-f bits.
  3. Evaluate the integer part by the weights 2n−f−1,…,202^{n-f-1},\ldots,2^0.
  4. Evaluate the fractional part by the weights 2−1,…,2−f2^{-1},\ldots,2^{-f}; collecting over the common denominator 2f2^f is quicker and less error-prone than adding decimals.
  5. Check with N/2fN/2^f.
  6. If the leading bit is 1, tabulate the signed alternatives as a labelled remark — a stated decision, not a hedged answer.

Worked Example

2026 Paper 2, 2026-P2-Q6b-i (8 marks)

Find the decimal equivalent of the following floating point 10-bit numbers with 5 bits as fractional part: 10101110111010111011 and 01001010100100101010.

Source: analysis/solutions/2026-P2-Q6b-i.md

Format. 1010 bits with 55 fractional bits is Q5.5Q5.5: five integer bits, the point, five fractional bits, read unsigned.

First word. 1010111011→10101 ⁣⋅ ⁣110111010111011\to 10101\!\cdot\!11011.

(10101)2=16+4+1=21,(0.11011)2=16+8+0+2+132=2732=0.84375,(10101)_2=16+4+1=21,\qquad (0.11011)_2=\frac{16+8+0+2+1}{32}=\frac{27}{32}=0.84375, ⇒ 21.84375.Check: (1010111011)2=699, 69932=21.84375 ✓\Rightarrow\ 21.84375.\qquad\text{Check: }(1010111011)_2=699,\ \tfrac{699}{32}=21.84375\ \checkmark

Second word. 0100101010→01001 ⁣⋅ ⁣010100100101010\to 01001\!\cdot\!01010.

(01001)2=9,(0.01010)2=0+8+0+2+032=1032=0.3125,(01001)_2=9,\qquad (0.01010)_2=\frac{0+8+0+2+0}{32}=\frac{10}{32}=0.3125, ⇒ 9.3125.Check: (0100101010)2=298, 29832=9.3125 ✓\Rightarrow\ 9.3125.\qquad\text{Check: }(0100101010)_2=298,\ \tfrac{298}{32}=9.3125\ \checkmark 21.84375and9.3125\boxed{21.84375\quad\text{and}\quad 9.3125}

Both terminate in five decimals, as every Q5.5Q5.5 word must.

The signed readings, as a labelled remark. The second word begins with 00 and is +9.3125+9.3125 under every convention. Only the first is convention-sensitive:

Reading of 10101110111010111011Value
Unsigned Q5.5Q5.5 (the reading used)699/32=21.84375699/32=\mathbf{21.84375}
Sign–magnitude−(699−512)/32=−5.84375-(699-512)/32=-5.84375
Two’s complement(699−1024)/32=−10.15625(699-1024)/32=-10.15625

The unsigned reading is the one to present: the question supplies exactly one piece of format information — where the point sits — and supplies it for both numbers alike. Had a sign bit been intended, the integer field would be four bits, not five, and “5 bits as fractional part” would no longer determine the layout.

Common Traps

Marks-Aware Writing

At 5 marks, an efficient answer has five numbered steps: sign bit, binary conversion of ∣x∣|x|, normalisation showing ee, biased exponent computation and conversion to 11-bit binary, and the mantissa bits. Every step must be shown — the examiner cannot award marks for a final bit pattern without the derivation. Stating the IEEE 754 field widths (1-11-52) in the opening line saves you from being penalised for the wrong layout.

Practice Set

Only one historical question on this atom (shown above).

Ready to drill what you just read?

Daily Practice turns these patterns into one adaptive set a day — practised daily until they're automatic, free for everyone.

See Daily Practice →

This chapter is part of the Maths Coverage Map — 14 years, mapped. Get the take-away PDF free.