teach-ict.com logo

THE education site for computer science and ICT

 

Logical operator

An 'operator' in maths is something that acts upon numbers, for example in 1+1 = 2 the 'operator' is addition and is shown as a + sign. The operator creates an output (result) in this case the number 2.

In the world of logic there are only two numbers involved, namely 1 and 0 otherwise known as binary.

A logical operator acts upon one or more binary inputs to produce an output (result)

These are the logical operators

AND - output is true if all inputs are true

OR - output is true if any inputs are true

NOT - output is true if the input is false

XOR or EXCLUSIVE OR - output is true if any of the inputs are true. If all inputs are true then the output is false.

In digital electronics, these operators are carried out using equivalent 'logic gate' hardware. For example the AND operation is carried out by an 'AND' gate and the 'NOT' operation is carried out by a 'NOT' gate or inverter as it is sometimes called.

A handy way of understanding the logical operators is to use a 'truth table'. These are the truth tables for each type, where A and B are binary inputs.

AND
A B Out
1
1
1
0
1
0
1
0
0
0
0
0
OR
A B Out
1
1
1
0
1
1
1
0
1
0
0
0
XOR
A B Out
1
1
0
0
1
1
1
0
1
0
0
0
NOT
A Out
1
0
0
1

 

Engineers also use 'Logic Algebra' or 'Boolean Algebra' to work out how a device such as a microprocessor is meant to work.


 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Logical operators