OCR Computing A-Level Revision

Operators

Arithmetic Operators (2.4.b)

Arithmetic logic is simply what is taught in maths - addition (+), subtraction (-), multiplication (*), and division (/). There are two unfamiliar operators though - DIV and MOD.

DIV divides a number, but ignores the remainder. For example, 13 / 5 is 2.6, so 13 DIV 5 would return 2, discarding the 0.6. Effectively, MOD is the opposite of DIV, as 13 MOD 5 would return 3, because 13 / 5 is 2 remainder 3.

Relational Operators (2.4.c)

Relational logic is also similar to maths. There are four key symbols to know:

== (sometimes just =) is equal to
<> or != is not equal to
< (<=) less than (or equal to)
> (>=) greater than (or equal to)

The result of relational logic is always boolean (true or false). The syntax is normally x != y, with the operands either side of the operator. The two operands (or inputs) should always be the same data type (it's impossible to tell if 2 <= "rabbit"!). Relational logic is often used in IF statements.

Boolean Operators (2.4.d)

There are three boolean operators which will be tested in the F452 exam - AND, OR, and NOT. NOT only has one operand, whereas AND and OR have two operands.

AND - if both the operands are true, the result will be true.
OR - if neither of the operands are false, then the result will be true.
NOT - also known as an inverter, because the result is always opposite to the operand (i.e. if the operand is true, the result will be false, and vice-versa).

Ordering and Parentheses (2.4.e)

Although some languages simply work from left to right, most follow BIDMAS (Brackets, Indicies, Division, Multiplication, Addition, Subtraction). Non-arithmetic logic should simply be followed from left to right.

It would be a good idea to practice evaluating logical and arithmetical expressions (2.4.f)