teach-ict.com logo

THE education site for computer science and ICT

Logical operator

A logical operator acts upon one or more binary inputs to produce a single binary output

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. But if all inputs are true then the output is false.

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

A good way of understanding the logical operators is to use a truth table that lists every possible combination of inputs and its output.

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

2020-10