Data types — AQA A-Level Computer Science
A data type defines the domain of values a variable can hold, the operations that can be performed upon it, and how it is stored in physical memory. In AQA A-Level Computer Science, students must master primitive types including integer, real, Boolean, character, and string, alongside their internal binary representations and efficiency considerations.
Data types explained
A data type defines the kind of value a variable or expression can hold, the set of operations that may legally be performed on it, and the way the value is stored in memory.
Read the full explanation
Typical data types include integer, real (floating point), character, string and Boolean. Choosing a data type determines what a program can do with a value: an integer supports arithmetic such as 7 + 3 but a Boolean supports logical operations such as AND and OR. Data types also constrain storage, since an integer is usually held in a fixed number of bits and a real number is held as a mantissa and exponent. Understanding the concept means recognising that the type, not just the visible value, governs behaviour. For example, the value 5 stored as an integer can be divided to give 2 under integer division, whereas the same value stored as a real gives 2.5.
Your focus
- Understand the concept of a data type.
Which command word is this?
Provide the exact standard data type name (e.g., 'Boolean' or 'Integer') without needing supporting arguments.
Data types exam tips
Topic Overview
Data types specify the attributes of data items, instructing the compiler or interpreter how bit patterns stored in registers and memory should be interpreted and manipulated. They enforce boundaries on variable values, define valid operations, and dictate physical memory allocation.
Mastery of data types is central to computer science, bridging low-level hardware architecture with high-level software engineering. In the AQA specification, a rigorous understanding prevents execution errors, eliminates vulnerabilities like buffer overflows, and ensures optimal space and time complexity across Paper 1 programming tasks and Paper 2 systems theory.
Key Concepts
- →Primitive data types (Integer, Real/Float, Character, Boolean) serve as the fundamental building blocks, while Composite types (String, Array, Record) are formed by combining primitives.
- →Internal representation dictates precision and range: two's complement for signed integers, IEEE 754 mantissa and exponent for floating-point reals, and ASCII/Unicode encoding tables for characters.
- →Type systems categorize programming languages as strongly or weakly typed, and statically or dynamically typed, impacting compile-time safety and runtime performance.
- →Type coercion refers to automatic type conversion performed by the interpreter/compiler, whereas type casting denotes an explicit conversion directed by the programmer.
Marking Points
- Defines a data type as specifying the kind of value, the permitted operations and the storage representation.
- Gives appropriate examples such as integer, real, character, string and Boolean.
- Explains that the type determines which operations are valid for a value.
- Shows that the same numerical value may behave differently under different types, for example integer versus real division.
- Links the data type to how the value is stored in memory.
Examiner Tips
- 💡Use a concrete example, such as integer versus real division, to show understanding rather than only stating a definition.
- 💡Define the concept in terms of value category, permitted operations and storage, since all three are credited ideas.
- 💡Keep definitions precise and avoid vague phrases such as 'type of data' without explaining what the type controls.
- 💡When asked to choose a data type in an exam question, always state the exact type name and follow with two distinct justifications: the nature of the data (range/characters) and the operations required.
- 💡Be precise with terminology: distinguish clearly between 'overflow' (value exceeds the maximum representable limit) and 'underflow' or 'truncation error' (value is too small to be differentiated from zero or loses decimal precision).
Common Mistakes
- Treats a data type as only the visible value rather than the category governing storage and operations; state that the type defines the category and its rules.
- Confuses data type with variable name or identifier; state that the name labels a value while the type defines what kind of value it is.
- Assumes all numbers behave identically regardless of type; explain that integer and real division produce different results.
- Assuming all decimal fractions can be represented exactly in binary floating-point; fractions whose denominators are not powers of two result in infinite recurring binary representations.
- Believing Boolean variables always occupy strictly one bit of physical RAM during program execution; architectures usually allocate a full byte (8 bits) for byte-addressability and memory alignment.
- Treating strings as numeric values when they contain digits, ignoring that arithmetic operations cannot be directly applied without explicit type casting.
Revision Plan
- 1Day 1-2: Memorise the definitions, standard bit-widths, and typical value ranges for all five primitive data types.
- 2Day 3-4: Practise identifying data types for ambiguous real-world data (dates, postcodes, currency, phone numbers) with written justifications.
- 3Day 5-6: Explore binary floating-point representation, focusing on how mantissa and exponent widths affect range versus precision.
- 4Day 7: Complete past AQA Paper 1 and Paper 2 questions testing data type selection, memory size calculations, and type casting.
Exam Question Types
- 📋Attribute mapping: Given a table of real-world entity records, choose the most appropriate data type and field length for each field.
- 📋Memory footprint calculation: Calculating total memory usage in bits or bytes for a given data structure containing mixed primitive types.
- 📋Comparative explanation: Explaining the architectural trade-offs between fixed-point and floating-point representations for real numbers.
Command Word Expectations (AQA)
Provide the exact standard data type name (e.g., 'Boolean' or 'Integer') without needing supporting arguments.
Provide explicit technical arguments explaining why an alternative data type is unsuitable (e.g., citing memory economy, leading zeros, or calculation requirements).
Detail the underlying mechanism step-by-step, such as how bit allocation causes truncation errors in floating-point representations.
How Students Lose Marks (Examiner Pitfalls)
Step-by-Step Worked Solutions
Question: A weather monitoring station records the following data points every minute: Station ID (e.g. 'WX-904'), Wind Direction in degrees (0 to 359 as whole numbers), Air Temperature in Celsius (e.g. -14.25), and Rain Detected (true/false). State the most appropriate primitive data type for each data point and calculate the minimum total storage required per record in bytes assuming 1-byte ASCII characters, 16-bit signed integers, standard 32-bit single-precision floating point, and single-bit Booleans.
- 1.Step 1: Identify the most suitable data type for each attribute based on requirements: Station ID contains letters and hyphens, requiring String; Wind Direction is a whole number (0-359), requiring Integer; Temperature requires fractional precision, requiring Real/Float; Rain Detected is binary state, requiring Boolean.
- 2.Step 2: Calculate storage for Station ID: 'WX-904' contains 6 characters. At 1 byte per ASCII character, 6 * 1 byte = 6 bytes.
- 3.Step 3: Calculate storage for Wind Direction: 16-bit integer = 2 bytes (holds 0 to 359 comfortably, as unsigned 8-bit only reaches 255).
- 4.Step 4: Calculate storage for Air Temperature: 32-bit single-precision floating-point = 4 bytes.
- 5.Step 5: Calculate storage for Rain Detected: 1 bit logical data. Rounded up to memory alignment / addressable unit if uncompressed, but theoretically 1 bit (or 1 byte allocated in typical runtime). For minimum theoretical storage: 1 bit.
- 6.Step 6: Sum the total minimum storage: 6 bytes + 2 bytes + 4 bytes = 12 bytes + 1 bit (or 13 bytes rounded to the nearest addressable byte).
Question: Explain why the value 0.1 cannot be represented with absolute exactness in a computer system using binary floating-point representation, and explain the practical consequence of this limitation during financial calculations.
- 1.Step 1: Analyze how fractional values are represented in binary. Binary fractions represent sums of negative powers of two (0.5, 0.25, 0.125, 0.0625, etc.).
- 2.Step 2: Determine binary equivalent of decimal 0.1. Successive multiplication by 2 shows 0.1 decimal becomes 0.0001100110011... recurring in base 2.
- 3.Step 3: Relate this to hardware constraints: A floating-point register has a finite number of bits for the mantissa (e.g., 23 bits in IEEE 754 single precision), necessitating truncation or rounding.
- 4.Step 4: Identify consequences: Repeated arithmetic using truncated values causes cumulative rounding error, leading to inaccurate financial totals and balance discrepancies.