I wrote my instructor a message, and this is what he sent back. I'm simply going to breakdown what he said, and hopefully, with some time, you guys can help me understand.
Logical AND, OR and NOT are more precise than when we use those terms in speaking. First, let's review the truth tables for each:
AND (&&)
0 && 0 = 0
0 && 1 = 0
1 && 0 = 0
1 && 1= 1
OR (||)
0 || 0 = 0
0 || 1 = 0
1 || 0 = 0
1 || 1= 1
NOT (!)
! 0 = 1
! 1 = 0
I don't understand these truth tables. Can someone explain?
If you take an AND and NOT it, you have a NAND: !(a&&b)
what is Nand saying? It's not boxes and chocolates? So, if boxes and chocolates come back as true, it's false and vice versa?
If you take an OR and NOT it, you have a NOR: !(a||b)
What is the Nor saying? It's neither beans or apples? So if beans or apples comes back as true, it's false?
All these things (AND, OR, NOT, NAND and OR) can be built in electronic parts and are known as 'gates'. Gates are the building blocks for the CPU in a computer.
How can AND, OR, NOT, NAND, and OR be built in electronic parts? Can someone give me a brief explanation.
Since these same logical operations are available to a programmer, a program can be written to simulate a computer.
Perhaps it's because I have issues with wording, but I didn't understand this sentence.
The NOT operator is most often used to test NOT equal (!=) or to test if a boolean is the opposite of what it claims. For example, if we have a boolean variable called isFast. NOT isFast (!isFast) would imply we are looking for when it's slow.
Why would we want this? I don't understand.
"Since !(temperature > 100) is equivalent to "is the temperature not greater than 100", wouldn't the answer to that question in all cases by "yes that's true". "
!(temperature > 100)
No. What you said next IS true.
Why isn't it true though? He didn't explain why.
"If the temperature is greater, it comes back as false.
If the temperature is not greater, it comes back as true. "
Wouldn't this be useful only if you want to trick someone? I'm not understanding."
Sometimes logic can get pretty tricky. So, we strive to keep it simple. Using NOT with less/greater than, may be confusing. Another way to express the same thing is
temperature <= 100
...which may be more clear?
That didn't make things clearer for me.
"If age is greater than 12 OR age is less than 62 then No matter what value is in age, one condition or the other must be true. That means the whole expression must always be true. This statement likely meant to use AND."
This is a case where English is not too precise.
12 < age || age < 62 yes, this would ALWAYS be true.
This part makes sense.
12 < age && age < 62 this describes what would usually be expressed like this: 12 < age < 62, or as the range of numbers between 12 and 62
The 12 < age < 62, or as the range of numbers between 12 and 62 confuses me. Why are we setting it up like 12 < age < 62?
I understand why it would make more sense to use and, however.
One more thing to consider; recall when you studied sets and number lines? You used the open and closed circle on the number line to indicate that a number was included or not:
< 100 - open circle, 100 is NOT included
<= 100 - closed circle, 100 IS included
I never used an open or closed circle, so I'm not sure what he's saying here.
I don't understand these truth tables. Can someone explain?
It's the rules of these operators.
AND (&&)
0 && 0 = 0
0 && 1 = 0
1 && 0 = 0
1 && 1= 1
AND operator takes two values, and gives a single value result. The input values (of which there are 2) can be 0, or 1.
0 && 0 = 0
If the two input value are 0, the output value is 0.
How can AND, OR, NOT, NAND, and OR be built in electronic parts?
I don't understand your question. Are you asking how electronic things work? That's a huge question.
You know what, forget everything you said above. Start again. With one question only. What is the very first thing you don't understand? The very first, simplest thing that you don't understand.
If input A is 0, and input B is 0, what's the answer? Look at the table. See the column for Input A as 0, see the row for input B as 0, what value does the table tell you?
Hold your finger to the top line. The top line shows all the possible values of "Input A", going along the top. You can see that there are two possible values for Input A. Can you tell me what the two possible values for Input A are?
Hold your finger to the left column. The left column shows all the possible values of "Input B". You can see that there are two possible values for Input B. Can you tell me what the two possible values for Input B are?