# Primitive Data Types

> Computer Science · CIE A-Level 9618
> Source: https://www.owlsprep.com/study/cie-9618-u10-primitive-data-types/

This sub-topic covers the core fundamental primitive data types specified in the CIE 9618 syllabus. You will learn their properties, storage ranges, and how to select the correct type for common programming scenarios.

**Prerequisites:** [Basic computer storage units (bits, bytes)](https://www.owlsprep.com/study/cie-9618-u03-data-representation-bits-bytes/)

## Learning objectives

- Distinguish between primitive and non-primitive data types as defined in CIE 9618
- Recall the four core primitive types specified in the syllabus
- Calculate the range of values for an integer primitive given its bit length
- Select and justify the appropriate primitive type for any given use case

## Primitive vs Non-Primitive Data Types

Primitive data types are the most basic building blocks of data storage in programming. All more complex data structures are built by combining primitive types. A key defining feature is that a primitive variable holds a single value directly, rather than a reference or collection of other values.

**Primitive Data Type** — A native, basic data type provided by a programming language that stores a single value, and is not built from other data types.

*Example:* An integer storing 42 is primitive; an array of 10 integers is non-primitive.

> **tip**
>
> In CIE 9618 exams, you will always be expected to distinguish primitive from non-primitive types in multiple choice and short answer questions.

**Worked example:** Classify each of the following as primitive or non-primitive: (1) A boolean storing the result of a test, (2) A string storing a username, (3) A real number storing a temperature.

1. Recall that primitive types hold single basic values, non-primitive types are built from other types.
2. (1) A boolean holds one single logical value, so this is primitive.
3. (2) A string is a collection of character primitives, so this is non-primitive (CIE 9618 always classifies strings as non-primitive).
4. (3) A real number holds a single numeric value, so this is primitive.

## Core CIE 9618 Primitive Types

CIE 9618 specifies four core primitive data types that you must know for the exam, each with a clear purpose and set of allowed values.

- Integer: Stores whole numbers (positive, negative, or zero)
- Real (floating-point): Stores numbers with a fractional component
- Character: Stores a single alphanumeric character or symbol
- Boolean: Stores one of exactly two possible logical values

**Boolean Primitive** — A primitive type that can only hold one of two values, representing logical true and false. Used for conditional checks and flags.

*Notation:* bool

*Example:* isLoggedIn = true stores whether a user is currently logged into a system

**Worked example:** For each use case, state which core primitive type is most appropriate: (1) Number of students in a class, (2) Whether a user is logged in, (3) Price of an item, (4) First letter of a surname.

1. Match each use case to the properties of the four core primitive types:
2. 1. Number of students is a whole number with no fractional part → **Integer**
3. 2. Login status is either yes (true) or no (false) → **Boolean**
4. 3. Price has a fractional component (e.g. \$1.99) → **Real (floating-point)**
5. 4. First letter is a single symbol → **Character**

> **Exam tip:** Always stick to the four core types named in the CIE 9618 syllabus, even if other types are common in modern programming languages.

## Storage and Range of Primitive Types

Each primitive type requires a fixed amount of storage (in bits/bytes) depending on implementation. The amount of storage directly determines the range of possible values that the type can hold.

For integer primitives, the range depends on whether it is signed (supports negative values) or unsigned (only non-negative values):

- n-bit unsigned integer: range = $0$ to $2^n - 1$
- n-bit signed integer: range = $-2^{n-1}$ to $2^{n-1} - 1$

**Worked example:** What is the maximum positive value that can be stored in a 16-bit signed integer?

1. Use the formula for maximum value of an n-bit signed integer:
2. $$\text{Maximum} = 2^{n-1} - 1$$
3. Substitute n = 16:
4. $$2^{16-1} - 1 = 2^{15} - 1 = 32768 - 1 = 32767$$
5. The maximum positive value is 32767.

> **info**
>
> CIE 9618 regularly asks to calculate the range of an integer given its bit length, so memorize these two formulas.

## Selecting and Justifying Primitive Types

A common longer exam question asks you to suggest and justify the choice of primitive type for a given problem. You must match the type's properties to the requirements of the data being stored.

**Worked example:** A programmer wants to store the number of cars in a city car park with 250 spaces. Suggest and justify a suitable primitive type.

1. 1. First identify the data type: the number of cars is always a whole number with no fractional part.
2. 2. This matches the core definition of an integer primitive.
3. 3. Check range: possible values are 0 to 250, which fits well within the range of a standard 8-bit integer (max 255 for unsigned).
4. Conclusion: The most suitable primitive type is an integer.

**Exam command terms**

Common command terms for this topic in CIE 9618 exams:

- **Justify** — You must link your choice of type to the requirements of the data *(Mention that it stores whole numbers / fits the required range)*

- **Distinguish** — You must clearly state the key difference between primitive and non-primitive types *(Reference that primitives hold a single value, non-primitives are collections)*

## Common pitfalls

- **Wrong:** Classifying strings as primitive data types
  - Why it fails: Many programming languages treat strings as primitive, but CIE 9618 defines strings as non-primitive because they are collections of characters.
  - Correct: Always classify strings as non-primitive in CIE 9618 exams.
- **Wrong:** Using an integer to store measurements like height or weight
  - Why it fails: Most measurements have a fractional component that cannot be stored accurately as an integer.
  - Correct: Use a real (floating-point) primitive for measurements requiring fractional precision.
- **Wrong:** Mixing up the range formulas for signed and unsigned integers
  - Why it fails: Students often forget that signed integers use one bit for the sign, reducing the maximum positive value.
  - Correct: Memorize: unsigned = 0 to $2^n - 1$; signed = $-2^{n-1}$ to $2^{n-1} - 1$.
- **Wrong:** Using a character primitive to store a full phone number
  - Why it fails: A character can only hold one single digit/symbol, so it cannot store an entire 10+ digit phone number.
  - Correct: Use a non-primitive string to store a sequence of digits like a phone number.
- **Wrong:** Claiming booleans can store more than two values
  - Why it fails: A core defining property of the boolean primitive is that it only has two possible values by definition.
  - Correct: Always state that booleans can only hold true or false.

## Cheatsheet

| Primitive Type | Core Purpose | Example Value |
| --- | --- | --- |
| Integer | Whole numbers (no fraction) | 42 |
| Real | Numbers with fractional components | 1.75 |
| Character | Single alphanumeric symbol | 'Z' |
| Boolean | Logical true/false value | true |
| Formula | n-bit unsigned range | 0 to $2^n - 1$ |
| Formula | n-bit signed range | $-2^{n-1}$ to $2^{n-1} - 1$ |

## What's next

Now that you understand primitive data types, you are ready to learn about more complex non-primitive data types and data structures that form the core of Unit 10 for CIE 9618. Primitive types are the fundamental building blocks for all further work in programming, algorithms, and data representation, so mastering their properties and use cases will make every subsequent topic easier to understand. Common exam questions build on this topic to ask you to select appropriate data types for full programs, so this knowledge will be tested repeatedly in both papers. Next you will learn about structured non-primitive data types like arrays and records, which are built by combining multiple primitive values into a single usable structure.

- [Arrays](https://www.owlsprep.com/study/cie-9618-u10-arrays/)
- [Records](https://www.owlsprep.com/study/cie-9618-u10-records/)
- [Linked lists](https://www.owlsprep.com/study/cie-9618-u10-linked-lists/)

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/cie-9618-u10-primitive-data-types/
