Study Guide

Primitive Data Types

Computer ScienceΒ· Unit 10: Data types & structuresΒ· 10 min read

1. Primitive vs Non-Primitive Data Typesβ˜…β˜†β˜†β˜†β˜†β± 3 min

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.

πŸ“˜ Definition

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.

πŸ“ 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. 1

    Recall that primitive types hold single basic values, non-primitive types are built from other types.

  2. 2

    (1) A boolean holds one single logical value, so this is primitive.

  3. 3

    (2) A string is a collection of character primitives, so this is non-primitive (CIE 9618 always classifies strings as non-primitive).

  4. 4

    (3) A real number holds a single numeric value, so this is primitive.

2. Core CIE 9618 Primitive Typesβ˜…β˜…β˜†β˜†β˜†β± 4 min

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

πŸ“˜ Definition

Boolean Primitive

boolbool

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

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. 1

    Match each use case to the properties of the four core primitive types:

  2. 2
    1. Number of students is a whole number with no fractional part β†’ Integer
  3. 3
    1. Login status is either yes (true) or no (false) β†’ Boolean
  4. 4
    1. Price has a fractional component (e.g. $1.99) β†’ Real (floating-point)
  5. 5
    1. 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.

3. Storage and Range of Primitive Typesβ˜…β˜…β˜†β˜†β˜†β± 3 min

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 = to

  • n-bit signed integer: range = to

πŸ“ Worked Example

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

  1. 1

    Use the formula for maximum value of an n-bit signed integer:

  2. 2
    Maximum=2nβˆ’1βˆ’1\text{Maximum} = 2^{n-1} - 1
  3. 3

    Substitute n = 16:

  4. 4
    216βˆ’1βˆ’1=215βˆ’1=32768βˆ’1=327672^{16-1} - 1 = 2^{15} - 1 = 32768 - 1 = 32767
  5. 5

    The maximum positive value is 32767.

4. Selecting and Justifying Primitive Typesβ˜…β˜…β˜…β˜†β˜†β± 3 min

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
    1. First identify the data type: the number of cars is always a whole number with no fractional part.
  2. 2
    1. This matches the core definition of an integer primitive.
  3. 3
    1. 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. 4

    Conclusion: The most suitable primitive type is an integer.

5. Common Pitfalls

Wrong move:

Classifying strings as primitive data types

Why:

Many programming languages treat strings as primitive, but CIE 9618 defines strings as non-primitive because they are collections of characters.

Correct move:

Always classify strings as non-primitive in CIE 9618 exams.

Wrong move:

Using an integer to store measurements like height or weight

Why:

Most measurements have a fractional component that cannot be stored accurately as an integer.

Correct move:

Use a real (floating-point) primitive for measurements requiring fractional precision.

Wrong move:

Mixing up the range formulas for signed and unsigned integers

Why:

Students often forget that signed integers use one bit for the sign, reducing the maximum positive value.

Correct move:

Memorize: unsigned = 0 to ; signed = to .

Wrong move:

Using a character primitive to store a full phone number

Why:

A character can only hold one single digit/symbol, so it cannot store an entire 10+ digit phone number.

Correct move:

Use a non-primitive string to store a sequence of digits like a phone number.

Wrong move:

Claiming booleans can store more than two values

Why:

A core defining property of the boolean primitive is that it only has two possible values by definition.

Correct move:

Always state that booleans can only hold true or false.

6. Quick Reference 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

Formula

n-bit signed range

to

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

    Identify primitive data types

  • 2023 Β· 1

    Select suitable primitive type for use case

Going deeper

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.