Operators
OCR J277 Paper 2 expects you to know the symbol, name and effect of every operator on the spec. Mistakes with MOD, DIV, integer division and string comparison appear every year.
Arithmetic operators
| Symbol | Meaning | Example | Result |
|---|---|---|---|
| + | Addition | 7 + 3 | 10 |
| − | Subtraction | 7 − 3 | 4 |
| * | Multiplication | 7 * 3 | 21 |
| / | Division (real result) | 7 / 2 | 3.5 |
| MOD | Modulus — remainder of integer division | 7 MOD 3 | 1 |
| DIV | Integer division — quotient discarding remainder | 7 DIV 3 | 2 |
| ^ | Exponentiation (to the power of) | 2 ^ 3 | 8 |
Common uses of MOD and DIV
- isEven(x) — true if x MOD 2 = 0.
- Convert seconds to minutes and seconds — minutes = totalSeconds DIV 60; seconds = totalSeconds MOD 60.
- Last digit of an integer — n MOD 10.
Comparison (relational) operators
| Symbol | Meaning |
|---|---|
| = | Equal to |
| ≠ (or <>) | Not equal to |
| < | Less than |
| ≤ | Less than or equal to |
| > | Greater than |
| ≥ | Greater than or equal to |
Comparison operators always evaluate to a Boolean (TRUE / FALSE). They work on numbers and (in most languages) strings, where the comparison is alphabetical/lexicographic.
Boolean (logical) operators
| Operator | Effect |
|---|---|
| AND | TRUE only if both operands are TRUE |
| OR | TRUE if either operand (or both) is TRUE |
| NOT | Reverses the value (TRUE ↔ FALSE) |
Order of evaluation
In an expression, the order is usually:
- Brackets
- ^ (exponent)
- *, /, DIV, MOD
- +, -
- Comparison
- NOT, AND, OR (NOT first, then AND, then OR)
Use brackets when in doubt.
Common OCR exam mistakes
- Using / when DIV is needed (or vice-versa) — / returns a real, DIV returns an integer.
- Saying 7 MOD 3 = 2 — it is 1 (the remainder, not the quotient).
- Mixing up ≤ and < (boundary errors), or ≥ and >.
- Forgetting NOT has higher precedence than AND/OR.
- Using = for assignment in pseudocode where OCR uses ← — be careful in code-reading questions.
AI-generated · claude-opus-4-7 · v3-ocr-computer-science-leaves