1 00:00:00,600 --> 00:00:05,890 So let's take a look at the arithmetic operators and most of these you should be pretty familiar with. 2 00:00:06,420 --> 00:00:13,830 So there's addition which adds to numbers, subtraction, which subtracts one number from another multiplication. 3 00:00:14,340 --> 00:00:15,840 Multiply two numbers together. 4 00:00:16,560 --> 00:00:18,990 Division divides one number into another. 5 00:00:20,100 --> 00:00:21,350 Here's the first caveat. 6 00:00:21,360 --> 00:00:26,910 You cannot divide zero and zero because that will give you infinity. 7 00:00:27,390 --> 00:00:29,970 And that and computers have a problem with infinity. 8 00:00:31,890 --> 00:00:34,320 Now we get to a couple that maybe you haven't heard of. 9 00:00:34,320 --> 00:00:37,950 A remainder is the remainder of integer division. 10 00:00:39,000 --> 00:00:43,530 So is a division of five divided by two is to. 11 00:00:44,530 --> 00:00:49,720 Because you have an urgers, not 2.5, but the remainder is one. 12 00:00:51,600 --> 00:00:59,100 And then, exponentiation, there's something raised to a power like 10 to the third is one thousand. 13 00:01:00,550 --> 00:01:06,100 And then the unary plus, you don't see it as much, but sometimes you do that just as create a positive 14 00:01:06,100 --> 00:01:07,330 number out of a variable. 15 00:01:07,480 --> 00:01:12,060 And this is, you know, you need a variable and you don't need a variable. 16 00:01:12,070 --> 00:01:13,360 I'm sorry, you say plus five. 17 00:01:14,770 --> 00:01:19,630 So that just says make this a positive number and then the union minus is make this negative number. 18 00:01:19,630 --> 00:01:23,200 And you see this a little bit more often because you want to be able to say negative five, but you 19 00:01:23,200 --> 00:01:24,430 can also say negative X. 20 00:01:24,430 --> 00:01:27,970 So if X had the value of five, would not be negative five. 21 00:01:28,900 --> 00:01:32,050 If X had the value of negative five, it'd be five. 22 00:01:33,980 --> 00:01:40,670 And it does actually change the value of X it just as a result, I don't increment in order decrement 23 00:01:40,820 --> 00:01:42,680 operate on one variable there. 24 00:01:42,680 --> 00:01:43,240 Unary. 25 00:01:44,060 --> 00:01:47,390 And what they do is they either add one or they subtract one. 26 00:01:48,660 --> 00:01:57,690 The prefix double plus sign adds one or subtract one before the variable is used, the post fixed where 27 00:01:57,690 --> 00:02:04,620 the plus signs or the minus signs are on the right are incremented or decrements after the variables 28 00:02:04,620 --> 00:02:06,060 used as an example. 29 00:02:06,960 --> 00:02:08,250 Let's take a look at that next. 30 00:02:11,500 --> 00:02:17,930 Once again, I made a copy of the starter project, and so we're going to just remove this hello world. 31 00:02:17,950 --> 00:02:22,000 We don't need it and we'll do a little bit of operating. 32 00:02:23,080 --> 00:02:24,940 So some of this should be fairly obvious. 33 00:02:25,870 --> 00:02:29,440 And let's start out by doing some of them with literal values 34 00:02:32,710 --> 00:02:46,630 and we'll say five plus seven and let's make some copies of this and just do it for the basic arithmetic 35 00:02:46,630 --> 00:02:47,410 operations. 36 00:02:47,830 --> 00:02:49,570 Plus minus times divide. 37 00:02:55,630 --> 00:03:03,160 And is an asterisk and divide is a flash, let's go and run these and see the result. 38 00:03:06,760 --> 00:03:12,850 So 12 percent is 12 minutes is negative to five times. 39 00:03:12,850 --> 00:03:17,500 Seven is thirty five and five divided by seven, I'm assuming. 40 00:03:17,500 --> 00:03:21,640 Is this OK, let's keep going. 41 00:03:25,150 --> 00:03:30,590 So let's switch them around for the remainder because it makes a little more sense. 42 00:03:32,320 --> 00:03:33,880 Seven divided by five 43 00:03:37,660 --> 00:03:39,430 and do the remainder. 44 00:03:43,970 --> 00:03:54,380 And we'll also do a exponentiation or a power seven to the fifth power, so let's see what happens with 45 00:03:54,380 --> 00:03:54,770 those. 46 00:04:00,810 --> 00:04:03,900 So seven divided by five, that's this one point for. 47 00:04:05,250 --> 00:04:12,240 So that's the decimal version of it, seven remainder five is to. 48 00:04:13,660 --> 00:04:19,690 So, you see, if you did an integer division, it's just one, so you don't get the point four and 49 00:04:19,690 --> 00:04:25,720 there's a remainder of two and then seven to the fifth power of sixteen thousand eight hundred and seven. 50 00:04:27,620 --> 00:04:29,690 OK, these are all fairly straightforward. 51 00:04:30,680 --> 00:04:32,420 So what are we got next? 52 00:04:33,470 --> 00:04:37,370 OK, so next we'll do the unary plus in the unary minus. 53 00:04:41,270 --> 00:04:42,050 So. 54 00:04:45,910 --> 00:04:48,560 And Unary operates on only one variable. 55 00:04:49,150 --> 00:04:54,040 So if I say plus eight or minus eight, 56 00:04:57,640 --> 00:05:02,890 that gives us those values and that should be fairly obvious what's going to return? 57 00:05:04,400 --> 00:05:05,400 What Satan might have said. 58 00:05:06,290 --> 00:05:09,650 Now let's do the same thing with variables instead of literals. 59 00:05:10,590 --> 00:05:23,850 So let's see what's the quickest way I can make this happen, let's say let up or one equals five and 60 00:05:23,850 --> 00:05:33,630 what appear to equals seven and we'll make a copy of all these council logs 61 00:05:37,290 --> 00:05:38,220 and let's. 62 00:05:42,790 --> 00:05:43,690 Come at these up. 63 00:05:53,810 --> 00:05:56,630 So I'm going to do a replacement on five 64 00:05:58,940 --> 00:05:59,750 to. 65 00:06:02,760 --> 00:06:03,600 Offer one. 66 00:06:06,300 --> 00:06:08,070 And I'm just going to. 67 00:06:09,660 --> 00:06:14,130 Go past these, and so then I'll start clicking replace. 68 00:06:20,870 --> 00:06:25,490 Good beginnings, so then seven or two. 69 00:06:37,670 --> 00:06:38,200 OK. 70 00:06:40,780 --> 00:06:45,340 So replace those, let's just do this on Opper one 71 00:06:54,670 --> 00:06:57,760 and say we'll let it run. 72 00:07:00,290 --> 00:07:03,390 We'll tell you how I requested there to. 73 00:07:05,550 --> 00:07:08,070 Five, seven. 74 00:07:11,100 --> 00:07:16,950 A little bit too far, and so now I get the pretty much the same results, except we don't have eight 75 00:07:16,950 --> 00:07:20,450 and minus eight, but we have five and minus seven. 76 00:07:20,670 --> 00:07:23,150 So you see at minus the seven. 77 00:07:24,510 --> 00:07:24,880 All right. 78 00:07:24,900 --> 00:07:28,370 The only other one we need to look at is the decrements and the increment. 79 00:07:29,160 --> 00:07:32,730 So the way that works is we have our value. 80 00:07:32,730 --> 00:07:35,360 Opper one is five and you can't do it on a literal. 81 00:07:36,180 --> 00:07:48,330 So if I say council that log plus plus opper one and let's run, that's what happens. 82 00:07:52,610 --> 00:07:55,730 So opera one was five and six. 83 00:07:59,450 --> 00:08:00,440 What happens? 84 00:08:00,880 --> 00:08:03,200 What was removed from the confusion 85 00:08:06,260 --> 00:08:12,920 and let's just run it again, just to make sure we're clear so it's six because it incremented by one, 86 00:08:13,790 --> 00:08:16,970 but if I move the plus size to the end. 87 00:08:23,240 --> 00:08:24,190 We run that. 88 00:08:25,560 --> 00:08:35,610 It's still five, but it's not still five at the end, if I said console that log off or one without 89 00:08:35,610 --> 00:08:39,240 doing anything the second time, it'll have the value of six. 90 00:08:42,010 --> 00:08:48,680 So it was five, it was used in output with council dialogue, but it was enterable by one. 91 00:08:48,700 --> 00:08:51,220 So the next time we did it, Disvalue six. 92 00:08:55,690 --> 00:08:57,830 Decorating is the same sort of thing. 93 00:09:00,220 --> 00:09:04,690 So if I say minus minus one, An or one. 94 00:09:09,900 --> 00:09:10,910 He goes back to five. 95 00:09:12,600 --> 00:09:13,590 But if I do it. 96 00:09:16,720 --> 00:09:17,620 Postfix. 97 00:09:22,920 --> 00:09:25,430 It's took us back to five, but after the council walk. 98 00:09:27,770 --> 00:09:34,100 All right, one of the thing that I mentioned was order of precedence, so let's take a look at that. 99 00:09:36,670 --> 00:09:44,770 So I want to say that the fine, if I say 100 00:09:47,830 --> 00:10:05,720 let result equals offer one plus offered two times OP or two plus five, put a little one there. 101 00:10:07,630 --> 00:10:13,980 So this is five plus seven is 12 and produce 12. 102 00:10:13,990 --> 00:10:17,860 So 12 times seven is 80 for. 103 00:10:18,920 --> 00:10:21,530 Plus five is 89, but that's not what the results are going to be. 104 00:10:22,640 --> 00:10:29,480 And the reason is because let's just see, first of all, explain the reason. 105 00:10:39,450 --> 00:10:47,070 It's fifty nine, and the reason is because it does the the multiplication first, so does seven times 106 00:10:47,070 --> 00:10:49,680 seven is forty nine and then it does the adding. 107 00:10:50,550 --> 00:10:54,560 So 49 plus five is fifty four, plus five is fifty nine. 108 00:10:54,570 --> 00:10:55,730 That's the answer we got right. 109 00:10:56,460 --> 00:10:56,810 Yep. 110 00:10:57,720 --> 00:11:01,280 Now how can we get the answer that I originally thought we were going to get. 111 00:11:01,950 --> 00:11:10,830 We can get it by using parentheses to specify the order that things are going to happen by elevating 112 00:11:10,830 --> 00:11:11,560 the priority. 113 00:11:12,900 --> 00:11:18,300 So this is add them first and then multiply them. 114 00:11:24,300 --> 00:11:26,520 And I was totally off on what that came up with before. 115 00:11:27,860 --> 00:11:32,900 Well, that's because I was going left to right, so that would have been fine. 116 00:11:33,210 --> 00:11:35,000 Let's let's get the view I wanted before. 117 00:11:35,810 --> 00:11:41,090 So I didn't I wanted to add these first and then multiply times up or two and then add five. 118 00:11:47,670 --> 00:11:55,530 So that's at 89, and if I really want to be specific, I could put a parenthesis here and one here 119 00:11:56,250 --> 00:11:57,980 and that would really be specific. 120 00:11:57,990 --> 00:11:59,850 I could also do one here. 121 00:12:01,020 --> 00:12:08,070 And one out here, and that would really tell you that, hey, we have to do our for one plus up or 122 00:12:08,070 --> 00:12:13,060 two first and then we have to do time's up or two, and then we have to add five. 123 00:12:14,160 --> 00:12:15,510 So it's going to get the same result. 124 00:12:22,170 --> 00:12:25,350 So that's an introduction to arithmetic operations. 125 00:12:26,220 --> 00:12:28,260 Next, we'll look at relational operators.