DRIVE A: READY_
WELCOME!

You've found my articles! Please be kind and rewind.

C:\INSERTDISK2\ARTICLES\BINARY>

Boolean Logic

How computers use logic to make decisions using binary.

A battery, wire and light bulb

So far we have covered what binary is (Base 2 number system) and why computers actually use it (2 states is better than 10).

Next we need to know how computers actually use binary.

A Trip Back in Time

No, we aren't going to need a flux capacitor. Although, admittedly, it would be quite cool if we could.

To understand how computers make decisions using binary, we need to go back to the nineteenth century, to 1854, and a mathematician named George Boole who had just published a book with the very snappy title:

An Investigation of the Laws of Thought on which are Founded the Mathematical Theories of Logic and Probabilities

Victorian authors apparently believed that if the title didn't take ten minutes to read, it wasn't a proper book.

Charles Darwin wasn't exactly helping matters with On the Origin of Species by Means of Natural Selection, or the Preservation of Favoured Races in the Struggle for Life.

Thankfully, we can just call Boole's book The Laws of Thought.

George Boole was born in Lincoln in 1815, the son of a shoemaker. He had little formal education, but continued to teach himself, with help from his father. To the point that by the age of 19, he had started his own school. He would eventually become the first professor of mathematics at Queen's College, Cork, in Ireland. The college is now part of University College Cork.

I tell you all this because to say he knew his stuff would be an understatement.

Enter Boolean Algebra

Boole's work was groundbreaking because he developed a way of representing logic using algebra. Instead of using algebra to calculate with numbers, Boole used symbols and equations to represent logical statements and relationships.

His work became the foundation of what we now call Boolean algebra.

Don't worry about the name, I know it contains the word algebra which is enough to send shivers down the back as you remember the dreaded maths classroom but actually for the sake of this article forget the word algebra.

You see a logical statement can only have one of two possible outcomes:

  • True
  • False

And that's it folks, nothing else is acceptable as an answer. This is what makes it so simple.

Simple Logic Statements

Let's start with a really simple question:

IS IT RAINING?

Now we know there are only two possible answers:

  • True — it is raining.
  • False — it isn't raining.

Now let's change the question:

IS IT NOT RAINING?

This is where we introduce our first logical operator: NOT.

NOT simply reverses the answer.

If it is raining, then NOT raining is False. If it isn't raining, then NOT raining is True.

Basically, it's the Boolean equivalent of Yoda saying, "No. The opposite you must choose."

The AND Operator

Now things get slightly more interesting.

Imagine we ask:

IS IT RAINING AND DO I HAVE AN UMBRELLA?

The important word here is AND.

AND means that both conditions must be true before the overall answer becomes True.

We can call our two conditions:

  • R = It is raining
  • U = I have an umbrella

Our final result, which we'll call G, is True only when both R and U are True.

Raining Umbrella Go Outside
False False False
False True False
True False False
True True True

We've told the computer that both conditions must be true before it can say "Go Outside".

We can write this as:

G = R AND U

The OR Operator

Now let's try another logical operator: OR.

Suppose our question is:

IS IT NOT RAINING OR DO I HAVE AN UMBRELLA?

OR is different from AND.

With OR, only one of the conditions needs to be true for the result to be True.

Not Raining Umbrella Go Outside
False False False
False True True
True False True
True True True

If it's not raining, we can go outside.

If it is raining but we have an umbrella, we can also go outside.

If neither condition is true, we stay inside.

Boolean logic can also combine operators.

NOT Raining OR Umbrella

Raining Umbrella NOT Raining Result
False False True True
False True True True
True False False False
True True False True

But how does the computer physically perform these operations?

This is where gates come in.