1 00:00:01,620 --> 00:00:08,460 Come back in this lesson we are going to talk about the operators in Objective C and for the most part 2 00:00:08,460 --> 00:00:11,520 they would apply similarly to swithe. 3 00:00:11,700 --> 00:00:14,850 So there are several different types of operators. 4 00:00:14,850 --> 00:00:21,240 We have the AIs not the operators such as plus minus multiplication division so on and so forth. 5 00:00:21,330 --> 00:00:27,900 If you have the relational operators like the ones that we saw in a conditional if a statesman equality 6 00:00:27,900 --> 00:00:33,220 not equality larger or smaller larger than a quarter a smaller and equal. 7 00:00:33,450 --> 00:00:40,760 Logical ones like the ones that we saw in again and he felt a statement and or not. 8 00:00:40,890 --> 00:00:49,140 And we have the assignments one such as the one single equals sign plus equal sign minus equal sign 9 00:00:49,140 --> 00:00:50,510 and so on and so forth. 10 00:00:50,700 --> 00:00:53,360 For the most part these are quite simple. 11 00:00:53,480 --> 00:00:57,600 A few of them do they feel like we might have to talk about them. 12 00:00:57,600 --> 00:00:59,970 I would cover them in this lesson. 13 00:01:00,060 --> 00:01:03,450 So let's move on to ex-coach scored. 14 00:01:03,470 --> 00:01:10,020 I'm going to go ahead and close this project is start a new command line tool and this one I'm going 15 00:01:10,020 --> 00:01:14,390 to call it all prayed for this project. 16 00:01:14,430 --> 00:01:21,930 I'm so used to calling everything up because most often we do everything for us but I think here we 17 00:01:21,930 --> 00:01:24,160 do some things for our project. 18 00:01:24,160 --> 00:01:29,790 There are other command line tools and I don't want to type command line too it's just that such a long 19 00:01:29,790 --> 00:01:30,450 name. 20 00:01:30,750 --> 00:01:36,660 So in next quoting here I've got my diet and I'm going to get rid of all of that. 21 00:01:36,680 --> 00:01:40,940 I'm going to reformat everything nice and tidy and clean. 22 00:01:41,320 --> 00:01:42,660 And that's Lucar. 23 00:01:42,660 --> 00:01:44,440 Some of these things. 24 00:01:44,760 --> 00:01:51,630 So going back to my list the first one is the arithmetic operations and obviously plus minus what it 25 00:01:51,640 --> 00:01:53,890 became and division they make all the sense. 26 00:01:54,090 --> 00:01:57,490 These last three I need to speak about them really quickly. 27 00:01:57,690 --> 00:02:06,150 So the first one is the percentage sign which is the remainder or what we call modulus modulus which 28 00:02:06,150 --> 00:02:09,750 is the remainder of two values against each other. 29 00:02:09,990 --> 00:02:19,620 So here's how it works I'm going to say in my mod it's going to be 12 modulus 5. 30 00:02:19,710 --> 00:02:32,140 So if I print this volleyer now more is a percentage of my MOD. 31 00:02:32,340 --> 00:02:33,750 What do you think I'm going to get. 32 00:02:33,750 --> 00:02:36,380 What's the resort of 12. 33 00:02:36,400 --> 00:02:38,360 Modulus 5. 34 00:02:38,520 --> 00:02:40,110 Just to put that in context. 35 00:02:40,110 --> 00:02:44,730 If this is the first time you're seeing it or if you don't remember it from. 36 00:02:44,940 --> 00:02:51,420 I think most high schools at some point they cover this at least briefly or if you're new into programming 37 00:02:51,420 --> 00:02:55,460 generally this is a sign of remainder it means you fight. 38 00:02:55,460 --> 00:02:59,990 Divide the 12 way 5 foot is going to be remaining. 39 00:03:00,030 --> 00:03:03,970 So if you divide twenty five five you get to five. 40 00:03:04,010 --> 00:03:08,030 That is 10 12 minus 10 you will get two. 41 00:03:08,030 --> 00:03:10,050 So that is the result of that. 42 00:03:10,130 --> 00:03:14,840 And if I run this code are we we should get the exact same thing as well 43 00:03:17,760 --> 00:03:20,290 so it says more is. 44 00:03:20,470 --> 00:03:27,190 If I divide say 17 by 5 the result is going to be I think is again going to be true. 45 00:03:27,260 --> 00:03:28,420 Yeah it is. 46 00:03:29,020 --> 00:03:31,030 Let's see our example. 47 00:03:31,150 --> 00:03:39,970 A very large number such as this one modulus 13 you know for better numbers such as two or three or 48 00:03:39,970 --> 00:03:40,850 so on. 49 00:03:40,870 --> 00:03:47,440 There are formulas for finding them but for numbers just 13 it's quite difficult to find it so I'm actually 50 00:03:47,440 --> 00:03:54,880 going to go ahead and run this up on it tells me more this zero is actually this number can be divided 51 00:03:55,210 --> 00:04:01,080 by 13 which is so surprising thing so when you go ahead and redo it. 52 00:04:01,150 --> 00:04:09,340 So now we get 12 something to keep in mind which is very important is that whenever you get a modulus 53 00:04:09,340 --> 00:04:17,860 of any number against any are divided essentially that metanoia this number to say 6 the results that 54 00:04:17,860 --> 00:04:28,030 you can get are these 0 1 1 chance type 2 3 4 5. 55 00:04:28,110 --> 00:04:32,310 So the results of this number are either zero. 56 00:04:32,340 --> 00:04:38,780 It means this number perfectly divided by six or it is 1 or 2 or 4 8 to 5. 57 00:04:38,940 --> 00:04:47,460 Let me simplify this number so we can understand why if this number was 13 13 modulus 6 would be 1 because 58 00:04:47,460 --> 00:04:49,460 2 sixes are 12. 59 00:04:49,500 --> 00:04:53,900 If this number was 14 14 much of the 6 would be two. 60 00:04:54,120 --> 00:04:58,520 If this number was 15 50 miles the stakes would be three. 61 00:04:58,560 --> 00:05:04,300 If it was 16 would before if he was 17 it would be five. 62 00:05:04,470 --> 00:05:11,550 If it was 18 then it would then become 6 because it would divide one more time and would come back to 63 00:05:11,550 --> 00:05:12,400 zero. 64 00:05:12,510 --> 00:05:17,690 And that's what really helps us finding the remainder of a number. 65 00:05:17,700 --> 00:05:23,790 For instance if we want to find out if a number is order even I will essentially divide them by two. 66 00:05:24,000 --> 00:05:26,130 Let's go ahead and see that. 67 00:05:26,130 --> 00:05:40,110 So I'm going to say in my art number is this number and then I'm going to say in odd divide resolved 68 00:05:40,200 --> 00:05:56,190 is my number modulus 2 and then I'm going to say if the result is zero then it simply means it's even 69 00:05:56,690 --> 00:05:58,220 an event. 70 00:05:58,310 --> 00:06:01,350 Even so that's an odd number. 71 00:06:01,380 --> 00:06:03,920 I get the remainder of the games too. 72 00:06:03,990 --> 00:06:07,030 Depending on the result I decided that it is even. 73 00:06:07,150 --> 00:06:13,220 Or you could add the else statement and decide what it is or what it is. 74 00:06:13,550 --> 00:06:14,390 All right. 75 00:06:15,120 --> 00:06:19,100 So that is how you would find for instance an even number. 76 00:06:19,110 --> 00:06:21,790 Let me jump back to my presentation. 77 00:06:21,840 --> 00:06:27,260 The next thing that we should talk about these two sides the increments and decrements. 78 00:06:27,260 --> 00:06:35,420 So I have this number called my equals 23 for now. 79 00:06:35,820 --> 00:06:48,780 What happens when I say my ends plus plus Let's go ahead and say and like my eans now is percentage 80 00:06:48,860 --> 00:06:56,550 all and the value is my what do you think is going to happen. 81 00:06:56,550 --> 00:07:00,770 I'm sure most of you would guess that it's going to increment it by a number. 82 00:07:00,770 --> 00:07:05,080 So that's obviously the size of increments. 83 00:07:05,370 --> 00:07:11,070 And certainly this one would be decrements and that's about that. 84 00:07:11,070 --> 00:07:19,920 Another sign this is the science of assignment that we have talked about is I could simply say mine 85 00:07:20,250 --> 00:07:21,490 is 23. 86 00:07:21,690 --> 00:07:33,690 All I could say my wins plus equal three it means this is similar to saying this my ends so my end is 87 00:07:34,140 --> 00:07:36,730 my eans plus three. 88 00:07:36,750 --> 00:07:44,640 So this is a sign of get this add the 3 to it and put it back on itself just like what we had done earlier 89 00:07:44,640 --> 00:07:50,630 on using my een is my enough plus three all the other operations they work similarly. 90 00:07:50,640 --> 00:07:53,430 So this so to ask some puts it back inside. 91 00:07:53,610 --> 00:07:56,240 This multiplies and puts it back inside. 92 00:07:56,340 --> 00:08:02,200 This one divides them puts it back inside and this one finds the modulus and puts it back inside. 93 00:08:02,460 --> 00:08:04,020 Let's do a little game. 94 00:08:04,050 --> 00:08:08,390 So I have my integer 2 which is 23. 95 00:08:08,490 --> 00:08:20,100 I'm going to say my one plus equal three then I'm going to say my eans are division equal to and then 96 00:08:20,100 --> 00:08:27,510 I'm going to say my hands subtract equal 5. 97 00:08:27,510 --> 00:08:40,020 Then I'm going to say my hands multiply equal 8 and then I'm going to say let's say I'm losing count 98 00:08:40,020 --> 00:08:47,520 myself as to whether I'm doing my eans are modulus equal or 15. 99 00:08:47,520 --> 00:08:50,120 So what do you think is the result of this fun. 100 00:08:50,120 --> 00:08:52,260 Now luckily we don't have to guess. 101 00:08:52,300 --> 00:08:58,260 Raise is a percentage of my end. 102 00:08:58,890 --> 00:09:04,260 But before we go there I'm hoping that I'm doing the calculation right. 103 00:09:04,260 --> 00:09:06,670 I'm going to say my unit is 23. 104 00:09:06,900 --> 00:09:12,360 So 23 plus three that is 26 26 divided by two. 105 00:09:12,360 --> 00:09:15,270 That is 13 13 minus 5. 106 00:09:15,270 --> 00:09:18,300 That is 8 8 multiplied by 8. 107 00:09:18,300 --> 00:09:22,700 That is 64 64 modulus 15 is for. 108 00:09:22,920 --> 00:09:26,060 If I have done it right we should get to 4. 109 00:09:26,250 --> 00:09:26,980 That's wrong. 110 00:09:29,020 --> 00:09:31,070 I'm perfect result is for. 111 00:09:31,080 --> 00:09:40,150 So that is another thing we need to read it to understand that we can use these operations of assignments 112 00:09:40,170 --> 00:09:42,550 just think the very basic assignment. 113 00:09:42,660 --> 00:09:47,640 But this assignment IEDs divides multiplies and so on and so forth. 114 00:09:48,060 --> 00:09:55,350 So finally the last thing I want to talk about in this lesson is the priority of operators or the precedence 115 00:09:55,350 --> 00:09:56,840 of operators. 116 00:09:56,850 --> 00:10:11,110 Let me quickly demonstrate that by saying in my end is going to be 23 plus seven divided by seven modulus 117 00:10:11,200 --> 00:10:12,230 seven. 118 00:10:12,630 --> 00:10:15,480 What do you think is going to be the result of this. 119 00:10:15,480 --> 00:10:21,170 Which ones do they calculate first or do they get to be calculated first. 120 00:10:21,330 --> 00:10:27,100 And that's essentially the the the concept behind priority or precedence. 121 00:10:27,240 --> 00:10:34,860 So if I go ahead and say enough is percentage in my hands. 122 00:10:34,860 --> 00:10:36,900 Now we can see the result of it. 123 00:10:37,180 --> 00:10:43,190 And the important thing to understand here is this there aren't there vehicles being collected. 124 00:10:43,230 --> 00:10:47,180 Is that division or multiplication. 125 00:10:47,190 --> 00:10:48,960 They get the first priority. 126 00:10:48,960 --> 00:10:58,850 So essentially this happens first and then we get to do whatever is the result of that modulus by seven. 127 00:10:59,160 --> 00:11:00,750 And that happens. 128 00:11:00,750 --> 00:11:02,520 Second essentially. 129 00:11:03,000 --> 00:11:05,820 And then the plus happens at last. 130 00:11:05,820 --> 00:11:11,640 Now there are documents that one of them is the one I have shared with you guys with this lesson that 131 00:11:11,640 --> 00:11:14,870 explains the specifics of the priorities. 132 00:11:14,880 --> 00:11:20,820 It's kind of difficult to try and memorize all of them but what you want to make sure to know is that 133 00:11:21,240 --> 00:11:26,160 multiplication and division they have a priority over plus and minus. 134 00:11:26,160 --> 00:11:28,330 That's an important thing to remember. 135 00:11:28,470 --> 00:11:35,460 So modification of the vision ahead of plus minus and then from there on if you were in a situation 136 00:11:35,460 --> 00:11:41,610 that you needed to calculate this it makes all the sense that you actually put the practices behind 137 00:11:41,610 --> 00:11:43,170 them or around them. 138 00:11:43,170 --> 00:11:46,140 So for instance this very same piece of code. 139 00:11:46,350 --> 00:11:48,860 It could actually be interpreted like this. 140 00:11:48,870 --> 00:11:59,380 First get 23 at 7:53 then get seven modular set against seven and then divide them by each other which 141 00:11:59,390 --> 00:12:01,790 would be a totally different result. 142 00:12:01,800 --> 00:12:08,960 So to make sure that this kind of situation doesn't happen for you remember it always odds prothesis 143 00:12:09,000 --> 00:12:16,020 or at least in these early days until you have a better understanding and a more confidence in what 144 00:12:16,020 --> 00:12:17,580 you're doing exactly. 145 00:12:17,580 --> 00:12:21,590 So the goal here was to first divide 7 by 7. 146 00:12:21,600 --> 00:12:28,980 I would put them both within parties and then I would say well I want to make sure that this fall happens 147 00:12:28,980 --> 00:12:29,600 again. 148 00:12:29,640 --> 00:12:37,480 So within the practices and then the result of them will be on marginal us against 7. 149 00:12:37,500 --> 00:12:43,980 So keep that in mind that it really helps that you know you use some sort of brackets and make sure 150 00:12:43,980 --> 00:12:47,190 that you know exactly where you're going. 151 00:12:47,190 --> 00:12:55,590 The last thing I want to show you is this are vus if his statements are extensively over the past few 152 00:12:55,590 --> 00:12:56,450 lessons. 153 00:12:56,610 --> 00:13:08,090 And there's another kind of statement that you could use which is my sense is fine if it does then and 154 00:13:08,100 --> 00:13:16,590 it's like five else and it's like not five. 155 00:13:17,160 --> 00:13:27,290 So this is essentially called a terror Nery if it's a stunt like this for Nery are conditional. 156 00:13:27,600 --> 00:13:40,740 So it's basically a shorthand for saying if my eans is five then do something else do the other thing. 157 00:13:40,740 --> 00:13:47,100 So in this case we say my end is it equal to five if it is true. 158 00:13:47,310 --> 00:13:49,710 That's the sign of question mark. 159 00:13:49,740 --> 00:13:53,130 Then do this call is a sign of the else part. 160 00:13:53,140 --> 00:13:59,570 Do the other thing so just keep that in mind that sometimes you might see it in other people's code. 161 00:13:59,610 --> 00:14:06,270 I don't personally use it almost ever but you might find it useful or you might decide to use it. 162 00:14:06,840 --> 00:14:08,500 So that's of all the arts. 163 00:14:08,520 --> 00:14:12,490 We covered a lot of elements in this in this lesson. 164 00:14:12,500 --> 00:14:18,900 We went from operators to statesman's decremented instrumenting. 165 00:14:18,930 --> 00:14:20,990 Understanding what is modulars. 166 00:14:21,330 --> 00:14:24,120 I think we covered almost everything we needed. 167 00:14:24,570 --> 00:14:28,760 And with that in mind let's move on to our next lesson.