Application

A lot of people wonder why they need to learn the truth tables. The answer is: to understand what is going on.

There are numerous examples. Here are some brief examples:

Some of the “binary logic” methods are also used for “flow control” decisions. What this means is that the “binary logic” methods can frequently be used to compare bits and then to make decisions based on those comparisons.

Some of these processes are used in many situations. They are so frequently used, that programming languages typically assign symbols to these processes. For example, in the programming language called C, arithmetic like addition and subtraction is represented using symbols like + (the “plus sign”) and - (the “minus sign”). Some of these logic tables also have symbols, like & (the “ampersand”) representing “AND” logic, and | (the “pipe”, or sometimes called the “vertical bar”) representing “OR” logic, and ^ (the “caret”) representing XOR logic. (Not all programming languages use the same symbols. For example, in the programming language called BASIC, ^ refers to “raising” a number to a power.)

Not only is this logic useful for software developers and people handling pre-built equipment, this logic is useful for hardware designers. The process of performing any of these types of logic (like “NOR logic”, for example) is a process that is relatively easy to implement with very basic electronic circuitry. These processes might take a bit of time to learn and understand, but then they are quite simple to make happen. The fact that these processes are so simple to build is a key reason why computers can perform these processes so fast.

Numerical Truth

Very often, programmers uses the following values for numbers:

For example, in the language of C, an integer can be treated as the value “true” or “false”. The numbers 17 (seventeen) and -100 (negative one hundred) and 3941 (three thousand nine hundred forty one) are all treated as being “true”, because they are not zero. The only number that is false is zero.

In C, this can be convenient, because a program can contain code that says “if(number)”. The behavior of the program will depend on whether the value is “zero”, or a different behavior.

This is one standard approach to handling numbers. Programming languages use this standard, and even CPUs are designed around this standard. The “return codes” (also known as the “error codes”) of software programs is based on an inversion of this same standard. Perhaps another standard could have worked just as well: There might not be a particular reason why the value “zero” was determined to be “false”. However, regardless of why that standard was decided, the simple truth is that this standard is widely recognized. Many computer experts may expect that many other computer experts are familiar with this standard. And, knowing this standard will help to understand much of the rest of this guide.

When dealing with binary numbers, there only two possible values for each digit: zero, and one. So, when dealing with a single bit, zero is treated as the “false” value, and one is treated as a value meaning “true”.

Understanding that system will help in understanding the explanations. Whenever a reference is made to a “false bit”, that is the same thing as referring to a “bit with the value cleared to zero”.

The “truth” tables are about zeros and ones. (The concept is that keeping track of zeros and ones is like keeping track of what is “false” and what is “true”.)

There are no half-truths. A binary value is either entirely true (so the bit is set to one) or the value is entirely false (so the bit is set to zero).

Purpose

The idea behind these unary and binary tables is to know what value goes into the column on the right, if values are known for all of the other columns.

(This may make more sense for people using languages that read from left to right: the right-most column is the last, concluding column. If somebody writes out the chart in this standard form, someone from another culture where writing goes from right-to-left might find that the chart seems a bit backwards, starting with the conclusion and then ending with the starting values.)

Unary I/O Tables

There are two possible Input/Output tables:

Identity
0|0
1|1
NOT
0|1
1|0

Both of these are very simple. In the “Identity” table, the column on the right will have a value that matches the value in the left column. That is so extremely simple, that the “Identity” table is rarely discussed. Nothing gets changed, and so people do not typically spend much time discussing what the results are.

The “NOT” table is also extremely simple: the value in the right column does not match what is in the left column. The logic in this table is actually used, and mentioned, frequently enough that programmers should become familiar with this concept. If a computer applies the “NOT” logic to a bit, that simply means that the value of the bit was either flipped from a zero to a one, or flipped from a value of one to a value of zero.

Binary “Truth Tables”

Here are the sixteen possible binary truth tables. Some tips will be provided to understand the values on each chart. However, just to show what the charts look like, this guide starts out by showing these charts.

False
00|0
01|0
10|0
11|0
AND
00|0
01|0
10|0
11|1
Only 1st
00|0
01|0
10|1
11|0
First
00|0
01|0
10|1
11|1
Only 2nd
00|0
01|1
10|0
11|0
Second
00|0
01|1
10|0
11|1
XOR
00|0
01|1
10|1
11|0
OR
00|0
01|1
10|1
11|1
NOR
00|1
01|0
10|0
11|0
XNOR (Different)
00|1
01|0
10|0
11|1
NOT Second
00|1
01|0
10|1
11|0
NOT Only Second
00|1
01|0
10|1
11|1
NOT First
00|1
01|1
10|0
11|0
NOT Only First
00|1
01|1
10|0
11|1
NAND
00|1
01|1
10|1
11|0
True
00|1
01|1
10|1
11|1

Understanding Binary “Truth Tables”

For each table, the columns may be given the following titles: the first column is “First Input”, the second column is “Second Input”, and the next column of numbers is the “Output” (also known as the “Result”).

The names of each one of these tables are different, and so are the values in the last column.

The first two columns

The values in the first two columns are simply showing every possible combination of input values. So, every table shows this general layout:

Table
00|?
01|?
10|?
11|?

As mentioned earlier, the idea of each one of these tables is to determine the value in the last column, based on each of the other columns. These tables provide answers: they show the results of applying a certain type of “binary logic” to bits. For example, the one of these types of “binary logic” is the “NAND logic”. The “NAND logic” can be used with two bits. So, if the first bit is a one, and the second bit is a zero, what is the result?

NAND
10|?

This table is asking: after performing the process of applying the “NAND logic” on these bits, what will the result be?

The answer is always the same. The answer will always be one. The reason that is a one, and not a zero, will be described a bit later. (These tables/charts are not designed to describe why the answer is a one. These tables/charts are simply showing what the answer will be.) The results are showin in the last column of the actual filled-out, complete version of the table, which shows:

NAND
10|1

Well, that is the answer if there is a one, and then a zero. What if the first bit is a zero, and then we have a one? Well, we simply look at another row on the chart.

NAND
01|1

There are four possibilities of values for the two bits, and so there are four rows in each chart. To make things simple, these charts show the rows in the same pattern: the values of the first two columns are treated like a single binary number, and then the rows are sorted numerically based on those numbers. (This will make more sense for people who are familar with counting in binary. Counting in binary is described by ][CyberPillar]['s “how to count” guide.)

However, some people might be a bit less careful about the order of each row. If they do that, they may still be able to create a chart that shows the correct logic. Many books and/or teachers just expect people to spend time simply memorizing certain tables, and they do not discuss the order of the rows at all. So, the order of the rows is not an official part of these well-known charts.

The third columns

By reading the third column of numbers vertically, this third column can be treated as a binary number. For example, the third column of numbers in the “XOR” table may be viewed as 0101. Similarly, the third column of numbers in the “OR” table may be viewed as 0111, and the third column of the “NOR” table may be viewed as 1000. Using that method, the values of the third columns were used to assign each table a number, and so these tables are presented in numerical order based on what shows up in the third column.

Reviewing the charts (further)

In general, the concept behind these tables is that the Output is based on the input.

Some of the simplest tables in this list do not require three columns, but here they are shown with three columns for consistency (so that they look like the other tables). The first table, “False”, and the last table, “True”, only require the Output column. This is because the value of the output column is always the same, no matter what shows up in the other columns.

Similarly, some tables really only pay attention to one of the input columns. For instance, with the sixth table, labeled “Second” (output value 0101), the value of the “Output”/“Result” column is simply the same value as what is shown in the “Second Input” column. As another example, the thirteenth table is called “NOT First”, and the value of the “Result” column is simply the opposite of what shows up in the value of the “First Input” column. Tables 0011, 0101 already mentioned, 1010, and 1100 can all be described as having a result that can be figured out by looking at only one of the input values. As already mentioned, the values in the “Output”/“Result” column of tables 0000 and 1111 can be figured out without paying attention to either input. So, six of the sixteen charts can determine the “Output”/“Result” column using zero or one of the input values, and not requiring the other input value.

So, half of the possible tables do not rely on both inputs. A lot of training material won't even bother showing all of these charts. Although all of these charts have input and output values that are binary numbers, some people would say that a table isn't “binary” unless both input values are required to determine the value in the output column. Tables like the eleventh table (1010, “Not Second”), may be called “unary”, referring to the fact that there is only one input that is required to figure out the result.

This guide is simply showing all of the tables, in order to clearly demonstrate every possibility. When there are two input bits, there are four possible combinations of input (which is why each table has four rows), and there are sixteen possible outputs.

Creating the charts

So, if we ignore the titles for a moment, the rest of the details related to the charts should be fairly easy to re-create for anybody who understands binary. If we ignore the titles, then the charts look like this:

?
00|0
01|0
10|0
11|0
?
00|0
01|0
10|0
11|1
?
00|0
01|0
10|1
11|0
?
00|0
01|0
10|1
11|1
?
00|0
01|1
10|0
11|0
?
00|0
01|1
10|0
11|1
?
00|0
01|1
10|1
11|0
?
00|0
01|1
10|1
11|1
?
00|1
01|0
10|0
11|0
?
00|1
01|0
10|0
11|1
?
00|1
01|0
10|1
11|0
?
00|1
01|0
10|1
11|1
?
00|1
01|1
10|0
11|0
?
00|1
01|1
10|0
11|1
?
00|1
01|1
10|1
11|0
?
00|1
01|1
10|1
11|1

So, the only thing left to filling out the charts is to know what to name them. The names of the “truth tables” are based on the logic that describes what happens when the “truth table” is applied. This will make more sense when the logic of the “truth tables” are explained. So, finally, let's cover that.

AND, (X)OR

Out of the binary truth tables, some of the most useful ones to discuss are generally the second table, which is “AND” (0001), as well as “XOR” (0110), as well as “OR” (0111).

Here are descriptions of each.

[#andlogic]:

AND

When we apply “AND” logic, the “Output”/”Result” is true if both of the input values are true.

To demonstrate this, let's look at each row of the chart, and compare that to normal (English) language.

00|?

The first two columns are zero, so we will treat those values as false. In this example, we will think about a person who makes two false statements. For example:

“The planet Earth is shaped like a cube, AND a nickle is usually worth seven dollars.”

If a person made two false statements, is the person telling the truth, or is the person a liar?

The answer is: the person is a liar. The person is saying something that is false. So, the “Result” (a.k.a. the “Output”) is false. The last column gets a zero.

00|0

Now, what happens if the person says something that is false, and then something that is true?

01|?

For example, what if this person stated:

“The planet Earth is shaped like a cube, AND a nickle is worth five cents.”

The person is still a liar. (Hate to break it to ya', but the planet Earth is not shaped like a cube.) So the “Output” column gets a zero, and the row in the table looks like this:

01|0

How about if things are done in the other order: the person says something that is true, and then something that is false:

01|?

For example, what if this person stated:

“The shape of a full moon looks like a circle, AND two plus two is equal to three trillion.”

Do we trust this person yet? No way! What we put into the last column is a zero. So, the end result is that the person is categorized as a liar. In other words, the combination of statements is not entirely true: it is false. So, a zero is placed in the end of the chart.

01|0

Finally, what if the person is actually making true statements, and is not making any false statements?

“The sky looks blue on sunny days, AND green grass is often healthier than brown grass.”

11|?

Alright! Now we have truth going on. Since both bits are true, the result is true.

11|1

So, the chart of “AND” logic ends up having these rows:

AND
00|0
01|0
10|0
11|1

This binary chart is what was created when thinking about how to apply the concept of “AND”. So, if someone wanted to give a binary to all of the possible binary truth tables, then the word “AND” would be an excellent name for this binary truth table.

If somebody built a piece of hardware called a “gate”, and that gate would output a value for “zero” unless all of the inputs were a value of “one”, then the name “AND” would be a very sensible name for that gate. The gate could be called an “AND gate”.

[#orlogic]:

OR

There are two “types” of “OR” logic. These two types have different names, which as “inclusive OR” and “exclusive OR”. By convention, “OR logic” refers to “inclusive OR”. (Some people may initially disagree with the decision behind this convention. However, the convention is extremely widespread amongst engineers and many other professionals, and so this convention absolutely should be solidly understood by people who use the term.) Both “inclusive OR” and “exclusive OR” are used regularly, so let's check out both of them.

[#orlogici]:

Inclusive OR

When we apply “inclusive ORAND” logic, the “Output”/”Result” is true if any of the input is true.

To demonstrate this, let's look at each row of the chart, and compare that to normal (English) language.

00|?

The first two columns are zero, so we will treat those values as false. In this example, we will think about a person who makes two false statements. For example:

“Today is Tuesday or Wednesday.”

Well, that's basically saying the same thing as:

“Today is Tuesday or today is Wednesday.”

Well, is that true or not? Hmm... Let's assume that somebody asked about what the current day was, and this was done on a Thursday. So this answer was given on a Thursday, so everything stated was false.

If a person made two false statements, is the person telling the truth, or is the person a liar?

The answer is: the person is a liar. Nothing the person said is true: everything that was stated was false. So, the person is treated as a liar. What this means is that the “Result” (a.k.a. the “Output”) is false. This column gets a zero.

00|0

Now, what happens if the person says two things, and only one of them is true?

01|?

For example, what if this person stated:

“Sharks are well known for eating lots of vegetables and penguins live in Antartica.”

This is true. (Not the part about sharks.)

01|1

How about if things are done in the other order: the person says something that is true, and then something that is false:

01|?

For example, what if this person stated:

“The earth's shape is similar to a ball, and two plus two is equal to three trillion.”

Is this person telling us any truth whatsoever? Yes, the person is being honest. One statement was true, and the word OR was used, so this is true. So, a one is placed in the end of the chart.

01|1

Finally, what if the person is actually making true statements, and is not making any false statements?

“The German flag or the American flag uses the color red.”

Once again, this can be broken down into statements:

“The German flag has red, or the American flag has red.”

11|?

Well, the German flag consists of three stripes: black on top, yellow (or gold?) on the bottom, and the middle is... red. The flag of the United States of America has some red stripes. So, both parts of the statement are true. The person combined these halves of the sentence using the word “or”.

Is the person making a true statement?

The answer to this will often spark some controversy among people who are being taught this for the first time. So, first the answer will be provided, and then an explanation on just how that makes sense.

The correct answer, amongst engineers and other professionals who may use this sort of terminology is:

Yes, the person is telling the truth.

11|1

Now, the controversy is that some people feel like the person is being misleading. After all, they didn't say “The German flag uses red, AND the American flag uses red.” The person essentially communicated that “The Germag flag uses red, OR the American flag uses red.” Doesn't this mean that only one statement can be true, and then the other statement needs to be false?

The answer is, no. If one statement has to be false, then that is what is called “exclusive OR”. Exclusive OR “excludes” the possibility that both bits are true. However, this is a different variation, called “inclusive OR”. With “inclusive OR”, this “includes” the possibility that both bits are true.

This will probably make a lot more sense if some other examples are considered.

All of these are true statements. So, the word “or” does not always mean “not both”.

This is similar to the phrase “and/or” (“and slash or”), which is commonly seen in writing (although used much less frequently in verbal conversations).

So, the chart of “OR” logic ends up having these rows:

OR
00|0
01|1
10|1
11|1

This binary chart is what was created when thinking about how to apply the concept of “OR”. So, if someone wanted to give a binary to all of the possible binary truth tables, then the word “OR” would be an excellent name for this binary truth table.

If somebody built a piece of hardware called a “gate”, and that gate would output a value for “zero” unless all of the inputs were a value of “one”, then the name “OR” would be a very sensible name for that gate. The gate could be called an “OR gate”.

[#xorlogic]:

Exclusive OR

XOR returns true if the input values are different.

We'll skip the examples about if zero or one statements are true. (They act the same as inclusive or.

Exclusive OR is like using the phrase “either” ... “or” ... “but not both”.

For example: She has $5. “She can afford a $3 item or a $4 item.”

Among experienced programmers, it seems that XOR (sometimes spelled as Xor or xor) is most commonly pronounced as “x or” (that is: “eks or”), although some people do pronounce it as “zor”. The term “zor” is sometimes a bit hard to understand, though, and so many times people who try to get away with saying “zor” will end up clarifying by saying “X or, exclusive or”, until it seems that they are being understood.

NAND, (X)NOR

NAND is equivilent to figuring out the results of applying “AND” logic, and then applying “NOT” to the result. There is no difference between “NAND” and “NOT AND”.

AND
00|0
01|0
10|0
11|1
NAND
00|1
01|1
10|1
11|0

NOR is equivilent to figuring out the results of applying “OR” logic, and then applying “NOT” to the result. There is no difference between “NOR” and “NOT OR”.

OR
00|0
01|1
10|1
11|1
NOR
00|1
01|0
10|0
11|0

XNOR is pronounced as “eks nor”.

XNOR is equivilent to figuring out the results of applying “XOR” logic, and then applying “NOT” to the result. There is no difference between “XNOR” and “NOT XOR”. Particularly when writing, sometimes people may refer to NXOR, which is the same thing as XNOR. When speaking, “X NOR” is the clear and short way to pronounce the name of this logic.

XOR
00|0
01|1
10|1
11|0
XOR
00|1
01|0
10|0
11|1

[#xand]:

XAND

There is truth table named “AND” and there is a table named “NAND”. There is a table named “OR” and a table named “NOR”. There is a table named “OR” and a table named “XOR” (and there is even an “XNOR”/“NXOR”). Some people feel like the pattern must continue, and so there must be a table named “XAND”. Similar to XOR, this would naturally mean “exclusive AND”.

Except, what does “exclusive AND” mean, exactly? “Exclusive OR” has a clear meaning: it is different than inclusive OR. “Exclusive OR” means “one bit, but not the other”. So, “exclusive AND” would mean one bit, but... what, exactly?

Perhaps the best answer is “One bit, and that bit exclusively, so not the other bit”. This is described by “truth table” 0010 (binary) and “truth table” 0100 (binary) (which are truth tables 2 and 4). If that was the case, then the NXAND tables would be table 1101 and table 1011.

However, suddenly we've gone from XAND being a name for a single table. Now, XAND is being treated as a name for a relationship which really describes two tables. This would suggest that there is no one single table that fits the XAND description better than every other table.

So, here is the common consensus that seems to have been agreed upon by more people than other other proposed consensus: there is no XAND table. Furthermore, when people are creating hardware to implement the logic of these truth tables, there is no single way to implement XAND. There is a such thing as a “NOR gate”, which is simple hardware that is used to implement the “NOR logic”. However, the most common consensus is that there is no such thing as a XAND gate. To summarize this very simple: XAND does not exist.

Now, this is simply the most common consensus. There are some people who have proposed other things. Patents have been filed by people who have claimed to invent a “XAND” gate/implementation. However, nobody trying to promote such a description of XAND has managed to achieve widespread consensus among most engineers.

[#xorpbarb]:

Legacy - References in Media

Xor sent Puff the Barbarian on his quest.