SLIDE 1 / 10
CSZone.co.uk
OCR H446 · Component 1 · 1.4.1

Primitive Data Types
& Binary Representation

OCR A Level Computer Science · cszone.co.uk
H446 SpecA Level
Learning Objectives

By the end of this topic you will be able to:

Identify and describe primitive data types: integer, real, Boolean, character, string
Represent unsigned integers in binary and convert between binary, denary and hexadecimal
Perform binary addition and recognise overflow
Understand the concepts of bits, bytes, nibbles and their relationship
Primitive Types

Primitive Data Types

TypeDescriptionExampleStorage
IntegerWhole numbers, positive or negative42, -7, 0Typically 32 or 64 bits
Real / FloatNumbers with a fractional part3.14, -0.532 or 64 bits (IEEE 754)
BooleanLogical value: True or False onlyTrue, False1 bit (stored as byte)
CharacterSingle symbol — letter, digit, special'A', '5', '!'1 byte (ASCII) / 2+ bytes (Unicode)
StringSequence of characters"Hello"Variable (n × char size)
All data in a computer is ultimately stored as binary (0s and 1s). The data type tells the computer how to interpret the binary pattern.
Binary

Binary Number System

Binary is base 2 — only digits 0 and 1. Each position represents a power of 2, doubling from right to left: 128, 64, 32, 16, 8, 4, 2, 1 for an 8-bit number.
Converting Binary → Denary
Example: 10110101
128+0+32+16+0+4+0+1 = 181

Method: write out powers of 2, multiply each by the corresponding bit, sum the results.
Converting Denary → Binary
Example: 181
181÷2=90r1, 90÷2=45r0, 45÷2=22r1, 22÷2=11r0, 11÷2=5r1, 5÷2=2r1, 2÷2=1r0, 1÷2=0r1
Read remainders upward: 10110101
Hexadecimal

Hexadecimal (Base 16)

Hexadecimal uses digits 0–9 and letters A–F (A=10, B=11, C=12, D=13, E=14, F=15). One hex digit represents exactly 4 bits (a nibble), so one byte = 2 hex digits.
Binary → Hex
Group binary into nibbles from right:
1011 0101
1011 = 11 = B
0101 = 5 = 5
Result: B5
Hex → Binary
Convert each hex digit to 4 bits:
3F
3 = 0011
F = 15 = 1111
Result: 0011 1111
Hex is used in computing because it is more compact and human-readable than binary. 8-bit binary (00101110) is more easily read as hex (2E). Commonly used for memory addresses, colour codes, and machine code.
Binary Addition

Binary Addition and Overflow

Binary addition rules: 0+0=0 · 0+1=1 · 1+0=1 · 1+1=10 (write 0, carry 1) · 1+1+1=11 (write 1, carry 1)
Example: 0110 1101 + 0001 1100
0110 1101
+ 0001 1100
──────────
1000 1001 = 137
Overflow
Overflow occurs when the result of an arithmetic operation is too large to be stored in the available number of bits. Example: adding two 8-bit numbers giving a result > 255 (unsigned) causes the carry bit to be lost, producing an incorrect result.
Exam Practice
OCR H446 Style · 4 marks
Convert the denary number 219 to: (a) 8-bit binary [1 mark] (b) hexadecimal [1 mark]. Then add 219 and 48 in binary and state whether overflow occurs using 8 bits [2 marks].
[4 marks]
1
(a) 219 in 8-bit binary: 128+64+16+8+2+1 = 1101 1011
1
(b) 1101 = D, 1011 = B → hexadecimal: DB
1
48 in binary = 0011 0000. 1101 1011 + 0011 0000 = 1 0000 1011. The 9th bit (carry) is produced.
1
Overflow does occur because the result (267) exceeds 255, which is the maximum value for an unsigned 8-bit integer. The carry bit is lost.
Common Mistakes

Don't Lose Marks

!
Writing binary conversions right to left then forgetting to reverse — when using the division-by-2 method, remainders are read from bottom to top (most significant bit first). Always double-check by converting back.
!
Forgetting to pad to 8 bits — if a binary result has fewer than 8 digits, pad with leading zeros. 10111 as an 8-bit number is 00010111. OCR mark schemes can penalise answers without correct bit width.
!
Confusing overflow with a carry — a carry out of the most significant bit does not always mean an error in unsigned arithmetic on its own, but if the result cannot be stored in the given bit width, that is overflow. Be precise about what overflows mean in context.
1.4.1a Complete
Well done! ✓
Primitive Data Types and Binary Representation
Return to lesson to continue