Binary representation of integers
CIE A-Level Computer ScienceΒ· Unit 1 Information Representation, Topic 2Β· 25 min read
1. Unsigned Binary Integersβ βββββ± 10 min
Unsigned Binary Integer
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.
Convert the 5-bit unsigned binary to decimal
- 1
Label each bit with its weight starting from at the right:
- 2
- 3
Multiply each bit by its weight and sum:
- 4
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.
Range of n-bit unsigned binary
Total unique values = . Range of values is to inclusive.
Find the range of 6-bit unsigned binary integers, how many unique values can it store?
- 1
Calculate total unique values for n=6 bits:
- 2
- 3
The maximum value is one less than the total number of values, since we start counting from 0:
- 4
- 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.
Two's Complement Signed Integer
Signed binary representation where the leftmost bit has weight , and all other bits follow standard unsigned weighting. This simplifies binary arithmetic.
Convert 5-bit two's complement to decimal
- 1
Calculate the negative weight for the leftmost bit:
- 2
- 3
List all bits and their weights:
- 4
- 5
Sum the weighted bits to get the final decimal value:
- 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.
Range of n-bit two's complement
Minimum (most negative) value = , maximum (most positive) value = , with total unique values.
What is the range of 8-bit two's complement signed integers?
- 1
Use the range formula for n=8 bits:
- 2
- 3
- 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.
