So let's take a look at the arithmetic operators and most of these you should be pretty familiar with.
So there's addition which adds to numbers, subtraction, which subtracts one number from another multiplication.
Multiply two numbers together.
Division divides one number into another.
Here's the first caveat.
You cannot divide zero and zero because that will give you infinity.
And that and computers have a problem with infinity.
Now we get to a couple that maybe you haven't heard of.
A remainder is the remainder of integer division.
So is a division of five divided by two is to.
Because you have an urgers, not 2.5, but the remainder is one.
And then, exponentiation, there's something raised to a power like 10 to the third is one thousand.
And then the unary plus, you don't see it as much, but sometimes you do that just as create a positive
number out of a variable.
And this is, you know, you need a variable and you don't need a variable.
I'm sorry, you say plus five.
So that just says make this a positive number and then the union minus is make this negative number.
And you see this a little bit more often because you want to be able to say negative five, but you
can also say negative X.
So if X had the value of five, would not be negative five.
If X had the value of negative five, it'd be five.
And it does actually change the value of X it just as a result, I don't increment in order decrement
operate on one variable there.
Unary.
And what they do is they either add one or they subtract one.
The prefix double plus sign adds one or subtract one before the variable is used, the post fixed where
the plus signs or the minus signs are on the right are incremented or decrements after the variables
used as an example.
Let's take a look at that next.
Once again, I made a copy of the starter project, and so we're going to just remove this hello world.
We don't need it and we'll do a little bit of operating.
So some of this should be fairly obvious.
And let's start out by doing some of them with literal values
and we'll say five plus seven and let's make some copies of this and just do it for the basic arithmetic
operations.
Plus minus times divide.
And is an asterisk and divide is a flash, let's go and run these and see the result.
So 12 percent is 12 minutes is negative to five times.
Seven is thirty five and five divided by seven, I'm assuming.
Is this OK, let's keep going.
So let's switch them around for the remainder because it makes a little more sense.
Seven divided by five
and do the remainder.
And we'll also do a exponentiation or a power seven to the fifth power, so let's see what happens with
those.
So seven divided by five, that's this one point for.
So that's the decimal version of it, seven remainder five is to.
So, you see, if you did an integer division, it's just one, so you don't get the point four and
there's a remainder of two and then seven to the fifth power of sixteen thousand eight hundred and seven.
OK, these are all fairly straightforward.
So what are we got next?
OK, so next we'll do the unary plus in the unary minus.
So.
And Unary operates on only one variable.
So if I say plus eight or minus eight,
that gives us those values and that should be fairly obvious what's going to return?
What Satan might have said.
Now let's do the same thing with variables instead of literals.
So let's see what's the quickest way I can make this happen, let's say let up or one equals five and
what appear to equals seven and we'll make a copy of all these council logs
and let's.
Come at these up.
So I'm going to do a replacement on five
to.
Offer one.
And I'm just going to.
Go past these, and so then I'll start clicking replace.
Good beginnings, so then seven or two.
OK.
So replace those, let's just do this on Opper one
and say we'll let it run.
We'll tell you how I requested there to.
Five, seven.
A little bit too far, and so now I get the pretty much the same results, except we don't have eight
and minus eight, but we have five and minus seven.
So you see at minus the seven.
All right.
The only other one we need to look at is the decrements and the increment.
So the way that works is we have our value.
Opper one is five and you can't do it on a literal.
So if I say council that log plus plus opper one and let's run, that's what happens.
So opera one was five and six.
What happens?
What was removed from the confusion
and let's just run it again, just to make sure we're clear so it's six because it incremented by one,
but if I move the plus size to the end.
We run that.
It's still five, but it's not still five at the end, if I said console that log off or one without
doing anything the second time, it'll have the value of six.
So it was five, it was used in output with council dialogue, but it was enterable by one.
So the next time we did it, Disvalue six.
Decorating is the same sort of thing.
So if I say minus minus one, An or one.
He goes back to five.
But if I do it.
Postfix.
It's took us back to five, but after the council walk.
All right, one of the thing that I mentioned was order of precedence, so let's take a look at that.
So I want to say that the fine, if I say
let result equals offer one plus offered two times OP or two plus five, put a little one there.
So this is five plus seven is 12 and produce 12.
So 12 times seven is 80 for.
Plus five is 89, but that's not what the results are going to be.
And the reason is because let's just see, first of all, explain the reason.
It's fifty nine, and the reason is because it does the the multiplication first, so does seven times
seven is forty nine and then it does the adding.
So 49 plus five is fifty four, plus five is fifty nine.
That's the answer we got right.
Yep.
Now how can we get the answer that I originally thought we were going to get.
We can get it by using parentheses to specify the order that things are going to happen by elevating
the priority.
So this is add them first and then multiply them.
And I was totally off on what that came up with before.
Well, that's because I was going left to right, so that would have been fine.
Let's let's get the view I wanted before.
So I didn't I wanted to add these first and then multiply times up or two and then add five.
So that's at 89, and if I really want to be specific, I could put a parenthesis here and one here
and that would really be specific.
I could also do one here.
And one out here, and that would really tell you that, hey, we have to do our for one plus up or
two first and then we have to do time's up or two, and then we have to add five.
So it's going to get the same result.
So that's an introduction to arithmetic operations.
Next, we'll look at relational operators.