Data representation - EduqasOperators

Binary data can represent numbers, graphics, sound and characters. It is then organised and manipulated differently. Data can also be stored in arrays, records or external files and go through validation or verification checks to ensure accuracy.

Part ofComputer ScienceUnderstanding Computer Science

Operators

In computer science, an is a character, or characters that determine the action that is to be performed or considered.

There are three types of operator that programmers use:

Mathematical operations

Computers are designed to carry out calculations. Mathematical operators allow arithmetic to be performed on values.

Mathematical operationOperatorExample
Addition
+
x = x + 5
Subtraction
-
x = x - 5
Multiplication
*
x = x * 5
Division
/
x = x / 5
Integer division
DIV
(finds the whole number after the division)
x = x DIV 5 
If
x
is 21, then the result of this is that
x
is 4
Remainder
MOD
(finds the remainder after the modulus division)
x = x MOD 5 
If
x
is 21, then the result of this is that
x
is 1
Mathematical operationAddition
Operator
+
Example
x = x + 5
Mathematical operationSubtraction
Operator
-
Example
x = x - 5
Mathematical operationMultiplication
Operator
*
Example
x = x * 5
Mathematical operationDivision
Operator
/
Example
x = x / 5
Mathematical operationInteger division
Operator
DIV
(finds the whole number after the division)
Example
x = x DIV 5 
If
x
is 21, then the result of this is that
x
is 4
Mathematical operationRemainder
Operator
MOD
(finds the remainder after the modulus division)
Example
x = x MOD 5 
If
x
is 21, then the result of this is that
x
is 1

Logical operators

Logical operators allow for and for comparisons to be made. They are used in testing.

Logical operationOperatorExample
Equivalence
==
if x == 5
Less than
<
if x < 5
Less than or equal to
<=
if x <= 5
Greater than
>
if x > 5
Greater than or equal to
>=
if x >= 5
Does not equal
<>
if x <> 5
Logical operationEquivalence
Operator
==
Example
if x == 5
Logical operationLess than
Operator
<
Example
if x < 5
Logical operationLess than or equal to
Operator
<=
Example
if x <= 5
Logical operationGreater than
Operator
>
Example
if x > 5
Logical operationGreater than or equal to
Operator
>=
Example
if x >= 5
Logical operationDoes not equal
Operator
<>
Example
if x <> 5