4.3.2

Boolean Logic

Test yourself

Boolean Operators

Boolean operators perform logical operations on boolean variables and always return another boolean variable.

Illustrative background for ANDIllustrative background for AND ?? "content

AND

  • AND evaluates to True (1) if and only if both operands are True (1).
  • '.' is the symbol for the AND operator.
Illustrative background for ORIllustrative background for OR ?? "content

OR

  • OR evaluates to True (1) if any of the two operands are True (1).
  • '+' is the symbol for the OR operator.
Illustrative background for NOT (negation)Illustrative background for NOT (negation) ?? "content

NOT (negation)

  • NOT negates a logical value.
  • The symbol for the NOT operator is a line above the variable.
  • For example, NOT AA is written as A\overline{A}.
Illustrative background for XORIllustrative background for XOR ?? "content

XOR

  • XOR means 'exclusive OR'.
  • The symbol for the XOR operator is \bigoplus.
Illustrative background for NANDIllustrative background for NAND ?? "content

NAND

  • NAND means NOT AND.
  • AA NAND BB is written as A.B\overline{A.B}.
Illustrative background for NORIllustrative background for NOR ?? "content

NOR

  • NOR means NOT OR.
  • AA NOR BB is written as A+B\overline{A+B}.

Evaluating Expressions

Logic gates can be combined to form logic circuits that process complex logical statements such as A AND (B OR C).

Illustrative background for Evaluating boolean expressionsIllustrative background for Evaluating boolean expressions ?? "content

Evaluating boolean expressions

  • To evaluate a boolean expression, you should substitute all of the values in for the variables and then use the definitions of the different boolean functions to simplify it one step at a time.
Illustrative background for Order of evaluationIllustrative background for Order of evaluation ?? "content

Order of evaluation

  • You should evaluate any expression in brackets first, for example:
    • NOT(True OR False).
    • NOT(True).
    • False.
Illustrative background for Truth tablesIllustrative background for Truth tables ?? "content

Truth tables

  • Another method of evaluating an expression is using a truth table.
  • A truth table shows every possible combination of inputs and the resulting output.
  • The truth table shows the input and output state for each combination.
  • The table can then be used to look up the output.

Defining Problems Using Boolean Logic

It is possible to describe the various outcomes of particular scenarios using boolean logic. The outcomes can then be interpreted using logic gates in an electronic circuit.

Illustrative background for Example 1Illustrative background for Example 1 ?? "content

Example 1

  • In order to pass an online course, students must achieve at least 75% in both assessments A and B.
Illustrative background for Booelan logicIllustrative background for Booelan logic ?? "content

Booelan logic

  • When approaching a problem like this, truth tables help to identify the possible outcomes.
  • Whether or not a student passed can be expressed as:
    • P=A.BP = A.B
Illustrative background for Example 2Illustrative background for Example 2 ?? "content

Example 2

  • A reef supplement should be added if the calcium level drops below 400 ppm or the magnesium drops below 1300 ppm, and the temperature of the water is 24°C.
Illustrative background for Booelan logicIllustrative background for Booelan logic ?? "content

Booelan logic

  • Whether or not the supplement is added can be expressed as:
    • D=(C+M).TD = (C + M).T

Jump to other topics

1Components of a Computer

2Software & Software Development

3Exchanging Data

4Data Types, Data Structures & Algorithms

5Legal, Moral, Cultural & Ethical Issues

6Elements of Computational Thinking

6.1Thinking Abstractly

6.2Thinking Procedurally

6.3Thinking Logically

7Problem Solving & Programming

8Algorithms

Go student ad image

Unlock your full potential with GoStudent tutoring

  • Affordable 1:1 tutoring from the comfort of your home

  • Tutors are matched to your specific learning needs

  • 30+ school subjects covered

Book a free trial lesson