He went over some boolean logic rules last time but we haven't learned what it means in C++ yet.
So to create a million variable we write them like this.
So we say pool just short for Boullion.
That's the type in which you give it the identifiers of hooly in my boolean
in course who's only have two values and they are of course true.
Or False and True or false are also keywords in C++ say true or false both keywords.
So there are also other operators that can evaluate to TRUE and FALSE.
The greater than sign less than sign and e greater than or equal to sign and the less than or equal
sign all of these will produce a true or false value.
So let's look an example.
Samian bhool results in 10 is greater than 3.
So this of course this is true.
Right.
So you can even put this out alue So it's
as it's.
It's
an see what happens.
So your result is 1.
So why is that.
Well booleans internally are represented by numbers so true here is represented by 1 and FALSE is represented
by 0.
In fact True's not actually are by one but that's the output.
It'll have to is really anything.
Except zero actually any number the size 0 is considered true in terms of boolean logic.
So there's also another operator that can evaluate to TRUE and FALSE which is the quality.
Operator So which is defined as two equal signs.
A lot of students will get this confused with the assignment operator as they both use equal signs and
just remember that if you're testing for equality you always want to use two equal science one equal
sign means assignment.
This means compare two or equals two.
Lot of students will get this mixed up and I certainly did.
I started at so.
Also keep in mind as well that it's comparing to floating point numbers.
It's with the equality sign is usually a bad idea.
And let's see why that is.
So safe float pie and fruit pie to say because it has two more values to it.
So let's compare PI with PI to and see what the result.
It's it's two.
It's this
in.
So there you go.
So their results is zero or false because the precision of pi 2 is not the same as the precision of
the first pi.
So if I said PI twos you put 1 4 and are in it again.
This is true but usually you'll see that floating point numbers are basically never the same.
You never really want to compare them as quality Neverland duty quality operation on two floats because
typically this will never be true.
But we will see later on how we can possibly fix this.
But for now just know that just don't compare to floating point numbers with a quality.
The other operator we can use.
Here is the inverse operator.
So let's say we had results.
Is Well it's actually called the not operator which is exclamation point to result.
So before we said this is false.
So these are not the same right.
But if we say result equals two not the result then it'll change whatever the value.
So let's try it again and we see
and we see that the result is 1 because it's switch or negated the false into a true.
So the opposite of false is true.
So there was actually another version of equality that we can use and it has to do with the not operator
in say not equal to this.
This says not equal to pi is not equal to pi 2.
So this should be true.
OK.
See.
So it's kind of like the opposite of the equal to.
Another way you can write this is say equal to here and then say not here.
This is equivalent
staff.
Yeah.
So the last two operators are what we covered last time which are the and logical and logical or.
So let's get rid of this
just right this one and let's say we had true.
And so we have to ampersands to make the logical answer remember that logical and is always to ampersands
and false is of course should be false.
Right.
So you're in this
you're in this it's false.
Ceara we want to do or say it or true or church two vertical bars.
So we have to ampersands four and in two vertical bars four or so.
True or false of course is true.
We want to make this false.
You say true or false or false horses false for some reason it never once printed out properly.
So the value of result is false.
So let's do a few examples and really try to solidify this a bit.
Let's use
that and say we hand who a equals true in Rule B is false in it's have some integers in each x 10 y
z or and you will have results.
Lool so it's is.
So it's a and b or x is greater than Y.
So what is the output of this do you think so.
A is true and B which is false will be false.
Cause for and both would have to be true.
For this to evaluate to true or X which is 10 y is zero.
So 10 of course is greater than zero.
So false or true is true.
See it right and we are.
So all your result is true.
One do another example
soon.
A not A
or B and.
X X X X less than or equal to y
k.
What would be the output here.
Well a is true.
So not a is false or false is totally false and X is 10 so x is not less than Y which is 0.
So this would also be false and the whole thing should be false.
So try and it's let's try one more
let's say not and those are using parentheses for these parentheses really do come in handy in especially
in boolean logic.
But any kind of earth Medich operation so let's say
next mission.
Actually equal.
Equal
today.
So what would be the results of this well.
True is definitely not equal to false and X is definitely not equal to whine because X is 10 and Y's
0.
So the whole thing should be false but it should be negated at the end.
Right and that's why we have these parentheses.
And the whole thing should be true.
And it is
so in the next lecture we'll be using this to actually start making our decisions in our output is.