✓ Free · Component 1 · 1.4.1 Data Types
1.4.1a Primitive Data Types and Binary Representation
OCR H446 · A Level Computer Science · ~14 min read
Notes
Video
Slides
Worksheet
Quiz

Primitive Data Types

A primitive data type is a basic data type built into the programming language. They are not composed of other types. The main primitive types in OCR H446 are:

TypeExample valuesStored asTypical size
Integer-3, 0, 42, 10000Two's complement binary32 or 64 bits
Real / Float3.14, -0.001, 2.0Floating point (IEEE 754)32 or 64 bits
BooleanTrue, False0 (False) or 1 (True)1 bit (often 1 byte)
Character'A', '?', '5'ASCII or Unicode code point8 bits (ASCII), 8–32 bits (Unicode)
String"Hello", "123"Sequence of character code pointsVariable (n × char size)

Note: a string is not truly primitive (it's a sequence of characters) but is often treated as a built-in type. OCR H446 includes it as a data type you must know.

Unsigned Binary Representation

All data in a computer is stored as binary (base 2) — sequences of 0s and 1s. An unsigned integer represents only non-negative values.

Each bit position has a place value that doubles as you move left:

Bit position76543210
Place value1286432168421

Converting Denary to Binary

Method: repeatedly divide by 2 and record remainders (bottom-up).

Example: Convert 75 to 8-bit binary 75 ÷ 2 = 37 r 1
37 ÷ 2 = 18 r 1
18 ÷ 2 = 9 r 0
9 ÷ 2 = 4 r 1
4 ÷ 2 = 2 r 0
2 ÷ 2 = 1 r 0
1 ÷ 2 = 0 r 1
Reading remainders bottom-up: 0100 1011
Check: 64+8+2+1 = 75 ✓

Converting Binary to Denary

Multiply each bit by its place value and sum the results.

Example: Convert 1011 0110 to denary 128×1 + 64×0 + 32×1 + 16×1 + 8×0 + 4×1 + 2×1 + 1×0
= 128 + 32 + 16 + 4 + 2 = 182

Hexadecimal

Hexadecimal (base 16) is a compact way to represent binary. Each hex digit represents exactly 4 bits (one nibble).

DenaryBinaryHexDenaryBinaryHex
000000810008
100011910019
200102101010A
300113111011B
401004121100C
501015131101D
601106141110E
701117151111F
Binary → Hex: Group into nibbles from the right 1011 0110 → B 6 → B6 (hex)

Hex → Binary: Replace each digit with 4-bit binary 3F → 0011 1111 → 0011 1111

Hex → Denary: Use place values (16¹, 16⁰) B6 → (11×16) + (6×1) = 176 + 6 = 182

Data Storage Units

UnitSize
Bit1 binary digit (0 or 1)
Nibble4 bits
Byte8 bits
Kilobyte (KB)1,000 bytes (SI) or 1,024 bytes (KiB)
Megabyte (MB)1,000,000 bytes (SI) or 1,048,576 bytes (MiB)
Gigabyte (GB)10⁹ bytes (SI) or 2³⁰ bytes (GiB)
Terabyte (TB)10¹² bytes (SI)

Number Ranges

With n bits, the number of distinct values that can be represented = 2ⁿ.

  • Unsigned n-bit integer: range 0 to 2ⁿ − 1
  • 8-bit unsigned: 0 to 255 (2⁸−1)
  • 16-bit unsigned: 0 to 65535 (2¹⁶−1)

Why Binary? Why Hexadecimal?

Computers use binary because digital circuits have two stable states (high/low voltage = 1/0). Hexadecimal is used as a shorthand because:

  • Long binary strings are hard to read and error-prone
  • Each hex digit maps exactly to 4 bits — easy conversion
  • Used in: memory addresses, colour codes (#FF5733), MAC addresses, IP addresses in IPv6, machine code debugging
Exam tip: To convert denary to binary, use the subtraction method: write out place values (128, 64, 32, 16, 8, 4, 2, 1), then subtract each from the number (put 1 if it fits, 0 if not). Practice both directions until you can do them without thinking.
Exam tip: Know hex digits A=10, B=11, C=12, D=13, E=14, F=15. To convert B6 to denary: B=11, so B6 = 11×16 + 6 = 182. To convert binary to hex: split into 4-bit groups from the right.
⚠ Common Mistakes
  • Forgetting to pad binary to 8 bits — 75 in binary is 01001011, not just 1001011. Always give the requested number of bits.
  • Thinking hex only goes 0–9 — remember A through F represent 10–15. The digit F = 15 = 1111 in binary.
  • Confusing a string representation of a number with its numeric value — '123' is a string (characters '1','2','3'), not the integer 123. A character is not the same as its ASCII code.
✓ Notes completed!
Video coming soon
Click to advance · Arrow keys also work
Click slide or press arrow keys to navigate

Worksheet — 1.4.1a Primitive Data Types & Binary

8 questions · 20 marks · instantly marked

Q1Name five primitive data types and for each give one example value and describe how it is stored in binary.[5 marks]
✓ Mark scheme
Integer (e.g. 42) — stored as two's complement binary; Real/Float (e.g. 3.14) — stored as floating point (IEEE 754 with sign, exponent, mantissa); Boolean (e.g. True) — stored as 0 (False) or 1 (True); Character (e.g. 'A') — stored as ASCII or Unicode code point (e.g. 'A' = 65 = 01000001); String (e.g. "Hello") — stored as a sequence of character code points. 1 mark for each type with correct example and storage description, up to 5.
Q2Convert the denary number 137 to 8-bit unsigned binary. Show your working.[3 marks]
✓ Mark scheme
Place values: 128 64 32 16 8 4 2 1. 137 ≥ 128 → 1, remainder 9. 9 < 64 → 0. 9 < 32 → 0. 9 < 16 → 0. 9 ≥ 8 → 1, remainder 1. 1 < 4 → 0. 1 < 2 → 0. 1 ≥ 1 → 1. Answer: 1000 1001 [3 marks — 1 for correct method, 1 for leading 1 at position 7, 1 for correct final answer]. Check: 128+8+1 = 137 ✓
Q3Convert the 8-bit binary number 01110101 to denary.[2 marks]
✓ Mark scheme
0×128 + 1×64 + 1×32 + 1×16 + 0×8 + 1×4 + 0×2 + 1×1 [1 for correct working/method] = 64+32+16+4+1 = 117 [1 for correct answer].
Q4Convert the hexadecimal number A9 to (a) binary and (b) denary.[3 marks]
✓ Mark scheme
(a) A = 1010, 9 = 1001 → binary: 1010 1001 [1]; (b) A9 in denary: A=10, so 10×16 + 9×1 = 160+9 = 169 [2 — 1 for correct working, 1 for correct answer].
Q5Convert the 8-bit binary number 11001110 to hexadecimal.[2 marks]
✓ Mark scheme
Split into nibbles: 1100 | 1110. 1100 = 12 = C; 1110 = 14 = E [1 for correct split and identification]; Answer: CE [1 for correct final answer].
Q6How many distinct values can be represented using 10 bits? What is the maximum unsigned integer that can be stored?[2 marks]
✓ Mark scheme
Number of distinct values = 2¹⁰ = 1024 [1]; Maximum unsigned value = 2¹⁰ − 1 = 1023 [1] (since values range from 0 to 1023).
Q7Give two reasons why hexadecimal is used in computing rather than binary for representing data.[2 marks]
✓ Mark scheme
Any two from: Hexadecimal is more compact/shorter to write — fewer digits needed to represent the same value [1]; Each hex digit maps exactly to 4 bits, making conversion between hex and binary fast and easy without calculation [1]; Long binary strings are difficult to read and easy to make errors in — hex is more human-readable [1]; Hexadecimal is widely used in debugging, memory addresses, colour codes, MAC addresses [1].
Q8Explain the difference between an integer and a real (float) data type. Give one example of a situation where each would be the appropriate choice.[3 marks]
✓ Mark scheme
Integer: whole number (positive, negative or zero); stored as two's complement binary; no fractional part [1]. Real/Float: number with a fractional part; stored as floating point (sign, exponent, mantissa/significand); can represent very large or very small values [1]. Example — integer: counting items in a shopping basket, loop counter, age in years; real: measuring temperature (36.6°C), price (£4.99), GPS coordinates [1].
Topic Quiz
1 of 15
You scored
out of 15
🎯

Mini Test — 1.4.1a Data Types & Binary

  • 10 questions · 10 marks · 10 minutes
  • 5 MCQ + 5 short answer
Card 1 of 15
Click to reveal
🎉
Complete!
TermDefinition
← 1.3.5c Transport, Network & Link Layers 1.4.1 Data Types Next: 1.4.1b Two's Complement & Hex →