Study Guide

Binary representation of integers

CIE A-Level Computer ScienceΒ· Unit 1 Information Representation, Topic 2Β· 25 min read

1. Unsigned Binary Integersβ˜…β˜†β˜†β˜†β˜†β± 10 min

πŸ“˜ Definition

Unsigned Binary Integer

nβˆ’bitunsignedn-bit unsigned

Representation of non-negative integers where each bit is weighted by a power of 2, starting from at the rightmost least significant bit.

Example:

4-bit unsigned can represent 0 through 15

To convert an unsigned binary number to decimal, multiply each bit by its weight and sum the results. To convert decimal to unsigned binary, repeatedly divide by 2, collect remainders, then reverse the order of remainders.

πŸ“ Worked Example

Convert the 5-bit unsigned binary to decimal

  1. 1

    Label each bit with its weight starting from at the right:

  2. 2
    Bit:10110Weight:2423222120=168421\text{Bit}: 1 \quad 0 \quad 1 \quad 1 \quad 0 \\ \text{Weight}: 2^4 \quad 2^3 \quad 2^2 \quad 2^1 \quad 2^0 = 16 \quad 8 \quad 4 \quad 2 \quad 1
  3. 3

    Multiply each bit by its weight and sum:

  4. 4
    (1Γ—16)+(0Γ—8)+(1Γ—4)+(1Γ—2)+(0Γ—1)=22(1 \times 16) + (0 \times 8) + (1 \times 4) + (1 \times 2) + (0 \times 1) = 22

Exam tip:

Always count bit positions starting from 0 at the right, not 1, to avoid incorrect weight calculations.

2. Range of Unsigned Binary Integersβ˜…β˜†β˜†β˜†β˜†β± 8 min

For n-bit unsigned binary, every combination of bits maps to a unique non-negative integer. The smallest value is 0 (all bits 0) and the largest value occurs when all bits are 1.

πŸ“˜ Definition

Range of n-bit unsigned binary

Total unique values = . Range of values is to inclusive.

πŸ“ Worked Example

Find the range of 6-bit unsigned binary integers, how many unique values can it store?

  1. 1

    Calculate total unique values for n=6 bits:

  2. 2
    2n=26=642^n = 2^6 = 64
  3. 3

    The maximum value is one less than the total number of values, since we start counting from 0:

  4. 4
    Minimum=0,Maximum=64βˆ’1=63\text{Minimum} = 0, \quad \text{Maximum} = 64 - 1 = 63
  5. 5

    Final result: 6-bit unsigned can store 64 unique values ranging from 0 to 63.

Exam tip:

CIE often asks for maximum value, not number of values β€” always remember to subtract 1 from .

3. Signed Binary: Two's Complementβ˜…β˜…β˜†β˜†β˜†β± 15 min

CIE 9618 exclusively tests two's complement for signed binary integers, which can represent both positive and negative values. The leftmost (most significant) bit has a negative weight, all other bits have positive weights.

πŸ“˜ Definition

Two's Complement Signed Integer

nβˆ’bittwoβ€²scomplementn-bit two's complement

Signed binary representation where the leftmost bit has weight , and all other bits follow standard unsigned weighting. This simplifies binary arithmetic.

πŸ“ Worked Example

Convert 5-bit two's complement to decimal

  1. 1

    Calculate the negative weight for the leftmost bit:

  2. 2
    n=5,Leftmost weight=βˆ’25βˆ’1=βˆ’16n=5, \quad \text{Leftmost weight} = -2^{5-1} = -16
  3. 3

    List all bits and their weights:

  4. 4
    Bit:11010Weight:βˆ’168421\text{Bit}: 1 \quad 1 \quad 0 \quad 1 \quad 0 \\ \text{Weight}: -16 \quad 8 \quad 4 \quad 2 \quad 1
  5. 5

    Sum the weighted bits to get the final decimal value:

  6. 6
    (1Γ—βˆ’16)+(1Γ—8)+(0Γ—4)+(1Γ—2)+(0Γ—1)=βˆ’6(1 \times -16) + (1 \times 8) + (0 \times 4) + (1 \times 2) + (0 \times 1) = -6

Exam tip:

Never forget the negative weight on the leading bit β€” this is the most common error in two's complement conversion.

4. Range of Two's Complement Integersβ˜…β˜…β˜†β˜†β˜†β± 10 min

One bit is reserved for the sign in two's complement, so the range is shifted to include negative values. The total number of unique values remains , same as unsigned for the same bit length.

πŸ“˜ Definition

Range of n-bit two's complement

Minimum (most negative) value = , maximum (most positive) value = , with total unique values.

πŸ“ Worked Example

What is the range of 8-bit two's complement signed integers?

  1. 1

    Use the range formula for n=8 bits:

  2. 2
    Minimum=βˆ’2nβˆ’1=βˆ’27=βˆ’128\text{Minimum} = -2^{n-1} = -2^{7} = -128
  3. 3
    Maximum=2nβˆ’1βˆ’1=27βˆ’1=127\text{Maximum} = 2^{n-1} - 1 = 2^7 - 1 = 127
  4. 4

    Final range: 8-bit two's complement can represent all integers from -128 to 127 inclusive, with 256 total unique values.

5. Common Pitfalls

Wrong move:

Stating the maximum value of n-bit unsigned binary as

Why:

The range starts at 0, so the maximum value is one less than the total number of possible bit combinations

Correct move:

Maximum value for n-bit unsigned binary is

Wrong move:

Giving the range of 8-bit two's complement as -127 to 128

Why:

The most negative value is , while the maximum is , so the negative range extends one further than the positive

Correct move:

Range of 8-bit two's complement is

Wrong move:

Using a positive weight for the leading bit when converting two's complement

Why:

The entire purpose of two's complement is to use a negative leading bit to represent negative values

Correct move:

Always multiply the leftmost bit of n-bit two's complement by

Wrong move:

Counting bit positions starting from 1 instead of 0 when calculating weights

Why:

The rightmost bit is , so shifting all positions by 1 gives an incorrect weight for every bit

Correct move:

Start counting positions from 0 at the rightmost least significant bit

Wrong move:

Claiming 4-bit unsigned can represent 16 values from 1 to 16

Why:

0 is a valid integer that requires a representation, so the range always starts at 0 for unsigned binary

Correct move:

4-bit unsigned ranges from 0 to 15, with 16 total unique values

6. Quick Reference Cheatsheet

Representation

Total unique values

Minimum value

Maximum value

n-bit unsigned

4-bit unsigned

16

8-bit unsigned

256

n-bit two's complement

4-bit two's complement

16

8-bit two's complement

256

When this came up on past exams

AI-estimated based on syllabus patterns β€” cross-check with official past papers for accuracy. Use only as revision-focus signals.

  • 2022 Β· 1

    Range of 8-bit two's complement

  • 2023 Β· 1

    Binary to decimal conversion

  • 2024 Β· 1

    Unsigned range calculation

Going deeper

What's Next

Binary integer representation is the foundational concept for all data storage in computer systems, and all subsequent topics in information representation build on this knowledge. Understanding bit length and range is critical for binary arithmetic, overflow errors, memory addressing, and representing other data types like fractions, text, images, and sound. Mastery of this sub-topic will make more advanced number representation concepts much easier to learn, and it appears in at least one question on almost every CIE 9618 Paper 1 exam.