1
00:00:02,470 --> 00:00:03,860
Hey What's up everybody.

2
00:00:03,880 --> 00:00:06,840
Mark Price read Zepps slopes dot com.

3
00:00:07,010 --> 00:00:10,310
And today we're going to talk about numbers.

4
00:00:10,400 --> 00:00:14,730
You're like wait a minute I thought we were doing programming what the heck are we doing.

5
00:00:14,730 --> 00:00:18,370
Going back to like fifth grade math first grade.

6
00:00:18,390 --> 00:00:20,690
Whenever you learn about numbers probably in kindergarten.

7
00:00:21,270 --> 00:00:21,840
Yeah that's right.

8
00:00:21,840 --> 00:00:25,510
Today's episode is brought to you by the number three.

9
00:00:26,180 --> 00:00:26,610
OK.

10
00:00:26,760 --> 00:00:33,390
So really though open up your tax code better and create a new playground if you're following along.

11
00:00:33,390 --> 00:00:34,910
Otherwise you can just watch.

12
00:00:35,190 --> 00:00:41,510
And we're going to call this one numbers and I'm going to create a new folder for a year.

13
00:00:41,580 --> 00:00:44,740
It's always nice to organize your code and projects in the folders.

14
00:00:44,820 --> 00:00:50,810
Swift and this one's going to be called numbers or save it here.

15
00:00:50,810 --> 00:00:58,100
So numbers are a core foundational building block to any programming language.

16
00:00:58,100 --> 00:01:03,250
And when you think about it you interact with numbers all the time in any application that you're using.

17
00:01:03,320 --> 00:01:07,970
For instance if you go to Wells-Fargo dot com to log to your bank account you're going to see your bank

18
00:01:07,970 --> 00:01:09,700
account balance and has numbers in it.

19
00:01:09,830 --> 00:01:10,400
OK.

20
00:01:10,490 --> 00:01:17,450
If you are using a workout app and one week you weighed like 150 pounds in the next week you weighed

21
00:01:17,450 --> 00:01:22,780
170 pounds because who knows what you're doing with yourself.

22
00:01:22,850 --> 00:01:24,560
You have to use numbers to show that to the user.

23
00:01:24,560 --> 00:01:25,450
Numbers everywhere.

24
00:01:25,460 --> 00:01:30,680
And it had to do math in order to calculate how many calories you consume in all those different things.

25
00:01:30,680 --> 00:01:36,730
So numbers are everywhere and every application just like this is a string and there's words and applications

26
00:01:36,740 --> 00:01:37,150
OK.

27
00:01:37,580 --> 00:01:39,440
Use numbers and use words.

28
00:01:39,470 --> 00:01:44,320
I know it sounds basic but those are foundational variable types in any language.

29
00:01:44,330 --> 00:01:49,850
But there's different types of numbers so let's get rid of this string variable here and let's create

30
00:01:49,850 --> 00:01:51,730
a new variable.

31
00:01:52,110 --> 00:01:52,910
Some numbers.

32
00:01:52,910 --> 00:01:59,260
Right now we don't just say bar some number you know equals number.

33
00:01:59,270 --> 00:02:03,480
You know there's no what is the number you know there's no real number OK.

34
00:02:03,680 --> 00:02:10,760
Well you have to do is actually create different types of numbers such as integers floats and doubles

35
00:02:11,330 --> 00:02:12,280
and more.

36
00:02:12,350 --> 00:02:20,240
So for instance if it were a person write a program for a person maybe this is one of those apps that

37
00:02:20,800 --> 00:02:25,550
calc calculates and tracks calorie burning and things like that shows you how much junk food you're

38
00:02:25,560 --> 00:02:26,460
eating you know.

39
00:02:26,470 --> 00:02:30,160
So let's go ahead and say well we have to have a profile.

40
00:02:30,170 --> 00:02:42,600
So we have an age right or not or ago a person has an age will say age 30 and let's say var weight.

41
00:02:42,890 --> 00:02:44,120
Well that's two pounds.

42
00:02:44,250 --> 00:02:47,410
That's how we roll in the US of A weight equals.

43
00:02:47,430 --> 00:02:49,440
We're going to say 200.

44
00:02:49,440 --> 00:02:52,020
So this person weighs 200 pounds OK.

45
00:02:52,470 --> 00:02:56,230
Does anyone know what variable type this is.

46
00:02:56,520 --> 00:02:57,010
OK.

47
00:02:57,210 --> 00:03:04,440
Well these are actually called int or integers but in swift The key word is actually into like so.

48
00:03:04,440 --> 00:03:11,250
So what we can do here is I can put a colon here and then I can put in the keyword and the variable

49
00:03:11,250 --> 00:03:11,570
name.

50
00:03:11,580 --> 00:03:19,260
And what we're doing right here is creating an explicitly declared type before we were creating a variable

51
00:03:19,260 --> 00:03:23,420
with an inferred type meaning the variable is smart enough to know what you're putting in it.

52
00:03:23,430 --> 00:03:26,710
And so it knows that it's and knows that it's an event.

53
00:03:26,730 --> 00:03:31,180
For instance I can't say age equals peanuts.

54
00:03:31,200 --> 00:03:38,940
I have to try and break the program that cannot assign value of type string to type int.

55
00:03:39,180 --> 00:03:44,280
OK so you cannot put different data types inside of a variable and it was smart enough to know that

56
00:03:44,280 --> 00:03:45,300
this was an int.

57
00:03:45,300 --> 00:03:46,900
So this is the key word here.

58
00:03:47,190 --> 00:03:52,350
This is an inferred or let's call this type inference.

59
00:03:52,440 --> 00:03:55,170
That's the proper term type inference.

60
00:03:55,170 --> 00:03:56,580
It inferred what type it was.

61
00:03:56,580 --> 00:04:01,500
It's no different than this except it did automatically and by the way this is the recommended way in

62
00:04:01,500 --> 00:04:06,480
swift if at all possible use type inference and you have to use an explicit declaration to do it.

63
00:04:06,480 --> 00:04:09,500
Don't just do this because you think it looks nicer.

64
00:04:09,550 --> 00:04:14,210
That's not the swift way with boys like this but this is an explicitly declared type.

65
00:04:14,220 --> 00:04:15,000
OK.

66
00:04:15,560 --> 00:04:20,420
So this isn't explicitly declared type.

67
00:04:20,430 --> 00:04:24,150
Those are the key words and phrases right there explicitly declared because we actually wrote what type

68
00:04:24,150 --> 00:04:25,140
it was.

69
00:04:25,200 --> 00:04:30,880
And again the same thing here we can't say weight equals no way.

70
00:04:31,360 --> 00:04:33,760
We can't can't spell either.

71
00:04:34,140 --> 00:04:35,540
That's why we need to work with numbers.

72
00:04:35,660 --> 00:04:36,040
OK.

73
00:04:36,270 --> 00:04:37,170
So can't do it right.

74
00:04:37,200 --> 00:04:39,290
It's the same exact thing no difference.

75
00:04:39,450 --> 00:04:41,150
So pretty cool.

76
00:04:41,160 --> 00:04:43,330
So we've got we've got some in here.

77
00:04:43,530 --> 00:04:44,740
And what is an integer.

78
00:04:45,000 --> 00:04:45,840
OK what is an integer.

79
00:04:45,840 --> 00:04:48,750
Well let's go pull open the Swift book.

80
00:04:48,750 --> 00:04:53,840
If you don't have it already and if you don't have it please get it.

81
00:04:53,940 --> 00:04:55,990
Go to books.

82
00:04:56,070 --> 00:04:57,670
This is super important.

83
00:04:57,690 --> 00:04:59,490
Get this book if you don't have it.

84
00:04:59,670 --> 00:05:06,560
I said go to books were already in books and then do a search for swift not Dora the Explorer.

85
00:05:06,570 --> 00:05:10,330
Dora meets Pablo That's my personal reading just forget that you saw that.

86
00:05:10,530 --> 00:05:12,740
And the swift program blinked.

87
00:05:12,750 --> 00:05:14,900
How did that get on here.

88
00:05:15,210 --> 00:05:18,080
Anyway it's with three editions the one that you want.

89
00:05:18,660 --> 00:05:20,040
That's right.

90
00:05:20,340 --> 00:05:22,740
Right here don't do the one with cocoa and object.

91
00:05:22,760 --> 00:05:26,920
You do this right here and get that book and read through the entire thing.

92
00:05:26,940 --> 00:05:33,030
I promise you won't you won't regret it and I'll make him much better programmer so integers are whole

93
00:05:33,030 --> 00:05:39,870
numbers with no fractional component such as 42 and negative 23 integers are either signed positive

94
00:05:39,870 --> 00:05:43,610
zero negative or unsigned positive or zero.

95
00:05:43,800 --> 00:05:50,730
So if preside signed an unsigned injures and eight 16 32 and 64 bit forms and what that means is 64

96
00:05:50,730 --> 00:05:56,010
bit 32 bit it's how many characters how many digits it can hold the actual value.

97
00:05:56,240 --> 00:05:59,650
You know if someone had a trillion dollar bank account.

98
00:05:59,880 --> 00:06:04,440
You know you're probably not going to use this energy and use something larger but Swift is smart enough

99
00:06:04,440 --> 00:06:08,460
to do all that for you automatically just know that there are some different things going on under the

100
00:06:08,460 --> 00:06:09,030
hood.

101
00:06:09,390 --> 00:06:15,110
And so you can see some of the types here like you and eight OK and a 32 bit sign in terms of type into

102
00:06:15,200 --> 00:06:16,320
32.

103
00:06:16,320 --> 00:06:18,490
So it just depends.

104
00:06:18,500 --> 00:06:19,830
It shows how much it holds.

105
00:06:19,830 --> 00:06:25,590
Again you don't ever need to worry about this and pretty much in swift for the most part you're never

106
00:06:25,680 --> 00:06:29,770
ever going to have to do anything else except this standard.

107
00:06:29,940 --> 00:06:32,780
Ok but again you can you can do different things.

108
00:06:32,790 --> 00:06:41,590
You know some of them you know and you could say you can't or is it you want eight 16 32 64.

109
00:06:41,760 --> 00:06:43,380
Now you can do different things like that.

110
00:06:43,500 --> 00:06:44,730
OK.

111
00:06:45,330 --> 00:06:47,260
But you don't want to be careful.

112
00:06:47,370 --> 00:06:48,390
You know you don't want to.

113
00:06:48,390 --> 00:06:54,060
You don't want to do something that you can't you can't do because it will overflow the variable into

114
00:06:54,060 --> 00:06:58,800
your literal overflows when stored and you it's too big too big of a number.

115
00:06:58,860 --> 00:07:03,510
And so again don't play around with the zombie like oh I want to be more memory efficient and use smaller

116
00:07:03,570 --> 00:07:04,380
integers.

117
00:07:04,390 --> 00:07:05,250
Now don't do that.

118
00:07:05,250 --> 00:07:07,860
Always always always use it.

119
00:07:07,980 --> 00:07:08,460
OK.

120
00:07:08,580 --> 00:07:11,220
Always always always use an integer.

121
00:07:11,370 --> 00:07:13,780
I think actually this one is too big even for integer.

122
00:07:13,920 --> 00:07:23,350
So in this case you probably have to use a data type that even longer like a long or something Swift

123
00:07:23,410 --> 00:07:27,440
I think it's a double with that did the trick.

124
00:07:27,440 --> 00:07:32,680
There you go doubles double precision double twice as long.

125
00:07:32,740 --> 00:07:33,740
More or less.

126
00:07:33,900 --> 00:07:39,090
Anyway there is another data type which allows you to have incredibly long values here.

127
00:07:39,100 --> 00:07:39,450
OK.

128
00:07:39,490 --> 00:07:40,690
Look this is just huge.

129
00:07:40,690 --> 00:07:42,160
I don't even know what number that is.

130
00:07:42,160 --> 00:07:45,510
OK so we have integer which you want to use at any given time.

131
00:07:45,520 --> 00:07:53,580
If a number does not have decimal points and note nothing no dot you know whatever you want to use it.

132
00:07:53,590 --> 00:07:53,980
OK.

133
00:07:53,980 --> 00:07:57,310
Always always always use it if you need a long number.

134
00:07:57,310 --> 00:08:00,080
Double is the favorite choice here.

135
00:08:00,220 --> 00:08:00,930
OK.

136
00:08:01,240 --> 00:08:04,790
So you can also double.

137
00:08:04,840 --> 00:08:05,830
This is cool.

138
00:08:06,280 --> 00:08:08,140
If you had something like let's say a bank account right.

139
00:08:08,140 --> 00:08:11,430
So actually no we're doing what are we doing here.

140
00:08:11,470 --> 00:08:15,570
We're doing an exercise Apso let's say Miles ran OK.

141
00:08:15,640 --> 00:08:18,970
Our Miles ran and we ran.

142
00:08:19,270 --> 00:08:20,230
Equals.

143
00:08:20,470 --> 00:08:21,410
We've run in the whole week.

144
00:08:21,410 --> 00:08:24,610
Fifty six point four five miles.

145
00:08:24,610 --> 00:08:27,610
So what type is this.

146
00:08:27,620 --> 00:08:31,290
This is actually a double.

147
00:08:31,720 --> 00:08:32,230
That's pretty cool.

148
00:08:32,230 --> 00:08:36,520
So by default swift uses doubles which has double the precision.

149
00:08:36,520 --> 00:08:41,690
In fact let's Ballman our handy dandy book here like I didn't pay X amount of dollars for this course

150
00:08:41,700 --> 00:08:42,970
or you can read a book to me.

151
00:08:43,030 --> 00:08:45,780
I wanted you to say those words without looking at a book.

152
00:08:46,060 --> 00:08:47,470
Does it make any sense.

153
00:08:47,470 --> 00:08:50,090
No it's better to have it straight from the horse's mouth.

154
00:08:50,110 --> 00:08:51,140
And I do this a lot.

155
00:08:51,290 --> 00:08:52,600
Get used to it.

156
00:08:52,600 --> 00:08:54,600
It is so important to read the documentation.

157
00:08:54,670 --> 00:08:58,710
Like seriously if you go to your boss every single day like how do you do this how do you do this he's

158
00:08:58,720 --> 00:08:59,620
going to fire you.

159
00:08:59,770 --> 00:09:02,850
I wouldn't have an employee like that you've got to learn how to learn.

160
00:09:02,860 --> 00:09:04,330
So always go back to the documentation.

161
00:09:04,330 --> 00:09:08,310
I'm trying to train you here how to be a lifelong learner and programmer.

162
00:09:08,320 --> 00:09:13,710
So where was I before I started lecturing you on things you don't even care about.

163
00:09:14,180 --> 00:09:14,390
OK.

164
00:09:14,400 --> 00:09:19,870
So we talk about integers now come floating point numbers floating point numbers or numbers with a fractional

165
00:09:19,870 --> 00:09:24,700
component such as 3.1 for maybe you're thinking wait you just did double wide.

166
00:09:24,870 --> 00:09:25,980
Why.

167
00:09:26,170 --> 00:09:28,060
Why didn't we do a float with the decimals.

168
00:09:28,060 --> 00:09:32,590
Well read this double as a precision of at least 15 decimal digits.

169
00:09:32,590 --> 00:09:34,480
OK so 15 decimal digits.

170
00:09:34,530 --> 00:09:37,850
Where is the precision of a flow can be as little as six decimal digits.

171
00:09:37,930 --> 00:09:42,040
The appropriate floating point type to use depends on the nature and range of values you need to work

172
00:09:42,040 --> 00:09:43,000
with in your code.

173
00:09:43,270 --> 00:09:47,770
In situations where either type would be appropriate double is preferred.

174
00:09:47,780 --> 00:09:50,110
OK so by default swift uses double.

175
00:09:50,330 --> 00:09:53,680
OK as you can tell it's a 64 bit floating point number.

176
00:09:53,680 --> 00:09:59,380
Very long a float cannot be as big and maybe you think it will should make the numbers I should say

177
00:09:59,380 --> 00:10:03,190
memory by using a flow and have a double no switch just I optimized under the hood.

178
00:10:03,500 --> 00:10:06,360
And it recommends that use double overflow and at a given time.

179
00:10:06,370 --> 00:10:09,070
So don't use a float unless you absolutely have to.

180
00:10:09,070 --> 00:10:12,010
Whereas in other languages float is the keyword in swift.

181
00:10:12,010 --> 00:10:14,130
Always use double double double double.

182
00:10:14,470 --> 00:10:15,170
OK.

183
00:10:15,450 --> 00:10:19,040
So just to show you that this is a double by default.

184
00:10:19,180 --> 00:10:26,950
If we do create a float let's say var pi equals three point one for k and then I say Miles Rand equals

185
00:10:27,280 --> 00:10:30,200
PI and for pi.

186
00:10:30,350 --> 00:10:33,000
Let's see what happens.

187
00:10:33,090 --> 00:10:38,790
Actually this is going to work because the double the flow will convert to double what I meant to do

188
00:10:39,150 --> 00:10:41,430
was pi equals milestone

189
00:10:45,250 --> 00:10:48,380
actually works interchangeably news to me.

190
00:10:48,400 --> 00:10:48,720
OK.

191
00:10:48,730 --> 00:10:54,960
So this is definitely a float though.

192
00:10:55,030 --> 00:10:55,840
Oh that's why.

193
00:10:56,020 --> 00:10:58,410
Ok guys I'm not smoking crack I promise.

194
00:10:58,450 --> 00:11:01,540
This is a it's because it was both a double and like tripping out.

195
00:11:01,560 --> 00:11:02,970
Why is it not working.

196
00:11:02,980 --> 00:11:03,430
OK.

197
00:11:03,580 --> 00:11:05,080
So there you go.

198
00:11:05,590 --> 00:11:05,800
OK.

199
00:11:05,810 --> 00:11:07,750
So pi is a float.

200
00:11:07,750 --> 00:11:08,430
Here we go.

201
00:11:08,470 --> 00:11:10,900
Can assign value of type double to type float.

202
00:11:10,900 --> 00:11:13,180
So clearly this is a double.

203
00:11:13,180 --> 00:11:14,460
And clearly this is a float.

204
00:11:14,560 --> 00:11:18,370
So the point I was trying to make is by default it always chooses a double when you use the decimal

205
00:11:18,370 --> 00:11:19,160
points.

206
00:11:19,240 --> 00:11:23,200
And so when you're creating your apps you're only going to really ever use and doubles for the most

207
00:11:23,200 --> 00:11:26,330
part when you're working with numbers which is really cool.

208
00:11:26,830 --> 00:11:35,380
And I encourage you to actually read a whole lot more in this swift book about wherever it went about

209
00:11:35,680 --> 00:11:40,570
all these different things because they has incredibly valuable information incredibly valuable and

210
00:11:40,570 --> 00:11:46,870
it's actually Britain written with the proper keywords because sometimes you may hear an instructor

211
00:11:46,870 --> 00:11:50,440
or somebody talking about programming in general they're not using the right terms or summarizing it

212
00:11:50,440 --> 00:11:54,790
Swift actually in those books they actually use the right keywords and they teach what's going on under

213
00:11:54,790 --> 00:12:00,600
the hood in a lot of cases so those numbers right and you can do a lot of things with numbers.

214
00:12:00,940 --> 00:12:04,090
And we talked in the earlier video about operators.

215
00:12:04,660 --> 00:12:07,280
You're going to use what's called a rith.

216
00:12:07,500 --> 00:12:12,050
Take my math.

217
00:12:12,460 --> 00:12:13,240
Oh my gosh.

218
00:12:13,330 --> 00:12:18,900
I'm sorry I just the arithmetic arithmetic.

219
00:12:18,910 --> 00:12:20,560
All right.

220
00:12:20,680 --> 00:12:26,120
Rith lactic arithmetic operators.

221
00:12:27,680 --> 00:12:31,450
If you're new to the class and you're wondering like why does he why does he leave some of the stuff

222
00:12:31,450 --> 00:12:34,870
in here like why do we make mistakes and things like that.

223
00:12:34,960 --> 00:12:37,470
And what happened was in the beginning I didn't always do that.

224
00:12:37,480 --> 00:12:40,620
I kind of cleaned up the code and made it look perfect.

225
00:12:40,630 --> 00:12:43,380
Sounds like you're doing it so perfectly.

226
00:12:43,540 --> 00:12:44,850
You're just so amazing.

227
00:12:44,860 --> 00:12:47,910
I'm never going to be a programmer because you can't do it perfectly.

228
00:12:47,940 --> 00:12:49,800
And I was it guys and gals.

229
00:12:49,870 --> 00:12:51,320
I'm not doing it perfectly.

230
00:12:51,340 --> 00:12:52,200
This is all edited.

231
00:12:52,200 --> 00:12:56,000
So I started making videos that were real like how programmers really solve problems.

232
00:12:56,020 --> 00:12:58,170
And then everyone's like I can do this.

233
00:12:58,210 --> 00:13:02,090
Mark prizes he's not a robot he's a real person who has to figure things out and use his brain.

234
00:13:02,110 --> 00:13:03,130
And that's why we do these things.

235
00:13:03,130 --> 00:13:08,080
That's why these videos are so informal because I pretend that you're sitting here right next to me

236
00:13:08,080 --> 00:13:11,460
in the class so I can actually teach and convey a message to you.

237
00:13:11,470 --> 00:13:13,900
So again if you're new to all this this is how we do it.

238
00:13:13,900 --> 00:13:16,650
All right dev slopes and it's exciting and people love it.

239
00:13:16,780 --> 00:13:20,290
If you hate it I'm sorry I just love it.

240
00:13:20,290 --> 00:13:20,520
OK.

241
00:13:20,530 --> 00:13:24,450
So arithmetic operators you know and this is just like in math and in high school right.

242
00:13:24,460 --> 00:13:25,570
Or grade school.

243
00:13:25,590 --> 00:13:25,950
Right.

244
00:13:26,020 --> 00:13:33,270
You know you get plus minus divide multiplication and things like that.

245
00:13:33,310 --> 00:13:37,780
And so you can actually you can actually play around with numbers which is kind of cool.

246
00:13:37,790 --> 00:13:42,280
One of my favorite ones is like doing the area of a shape or a rectangle.

247
00:13:42,280 --> 00:13:49,310
So a bar area equals and let's say lengths of 15 times with 20.

248
00:13:49,320 --> 00:13:49,830
OK.

249
00:13:50,140 --> 00:13:55,830
And we just did multiplication 315 times 20 which is really cool.

250
00:13:56,020 --> 00:13:57,530
And we can do addition as well.

251
00:13:57,550 --> 00:14:09,270
Var some equals five plus six bar diff for difference equals 10 minus 3 32 10 minus 3.

252
00:14:09,520 --> 00:14:12,830
And so we're doing different operations here which is really cool.

253
00:14:13,120 --> 00:14:13,900
What about division.

254
00:14:13,900 --> 00:14:14,790
Can we do division.

255
00:14:14,820 --> 00:14:27,910
Well yes we can we can say let's say 12 divided by groups some division 12 divided by three is four.

256
00:14:27,910 --> 00:14:28,520
OK.

257
00:14:28,930 --> 00:14:31,160
But there's one more thing I want to show you.

258
00:14:31,170 --> 00:14:32,940
OK.

259
00:14:33,370 --> 00:14:38,950
What if you said bar divide and we said what is 12 divided by five.

260
00:14:40,790 --> 00:14:46,550
Do you think it's going to be Hoopes this one equals 12 divided by five.

261
00:14:46,560 --> 00:14:48,360
And again these are just container names were given them.

262
00:14:48,360 --> 00:14:49,230
OK.

263
00:14:49,740 --> 00:14:51,210
So wait a minute.

264
00:14:51,360 --> 00:14:53,940
Twelve divided by five is not two words the remainder.

265
00:14:53,940 --> 00:15:00,230
There's got to be a remainder well in swift and pretty much every other programming language division

266
00:15:00,450 --> 00:15:03,460
or the arithmetic operator for division.

267
00:15:03,540 --> 00:15:11,880
This backslash here is only going to do the division and only give you how many times it goes into a

268
00:15:11,880 --> 00:15:12,250
number.

269
00:15:12,270 --> 00:15:14,650
The remainder actually is not going to be provided to you.

270
00:15:14,670 --> 00:15:21,630
So to get the remainder you actually have to use what's called the remainder operator or modulo or modulus.

271
00:15:21,630 --> 00:15:27,210
I've heard people say all kinds of things in called the modulo operators commonly use or the remainder

272
00:15:27,210 --> 00:15:30,330
operator that's what Swift calls the remainder operator.

273
00:15:30,330 --> 00:15:36,670
So the remainder operator is this equals 12 percent sign 5.

274
00:15:36,930 --> 00:15:40,480
OK so which is two.

275
00:15:40,500 --> 00:15:44,930
There's two of a remainder OK writes of five goes in the 12 two times with the remainder of two.

276
00:15:45,060 --> 00:15:51,030
In fact let's do 13 just to show you that these are different numbers here OK.

277
00:15:51,120 --> 00:15:56,070
So so if I wanted to show the full problem OK I could do something like this.

278
00:15:56,070 --> 00:15:59,930
Var result equals.

279
00:15:59,970 --> 00:16:00,920
This is gonna be a string right.

280
00:16:00,920 --> 00:16:09,600
So the result of 13 divided by five is OK.

281
00:16:10,290 --> 00:16:21,300
We can use string Interpol action here OK to insert a variable in and we can say Div 1 and we'll say

282
00:16:21,310 --> 00:16:28,370
dot for the decimal right with the remainder of.

283
00:16:29,160 --> 00:16:29,980
Not really.

284
00:16:30,000 --> 00:16:31,740
It's not really appropriate.

285
00:16:31,830 --> 00:16:41,530
5 is with a remainder of Arrigo and then we'll put in the remainder.

286
00:16:42,060 --> 00:16:48,660
So the result of 13 divided by five is to with a remainder of three.

287
00:16:48,890 --> 00:16:49,440
OK.

288
00:16:49,680 --> 00:16:51,530
And don't worry if you don't understand all this just yet.

289
00:16:51,570 --> 00:16:53,640
I'm just inserting variables into my string.

290
00:16:53,640 --> 00:16:55,490
Here's the print out to the screen.

291
00:16:55,530 --> 00:16:57,730
So what happens with the remainder operator.

292
00:16:57,750 --> 00:16:59,160
Is it going to do the division.

293
00:16:59,340 --> 00:17:02,310
But instead of returning the first number it's going returned the remainder.

294
00:17:02,310 --> 00:17:11,190
If there is a remainder and this is a great way to determine what numbers are even or odd even numbers

295
00:17:11,460 --> 00:17:16,980
will have no remainder I say if I wanted to know if number was even or odd slow say bar random number

296
00:17:17,400 --> 00:17:19,140
equals 13.

297
00:17:19,140 --> 00:17:25,800
So we can say if random number modulo two equals zero.

298
00:17:25,800 --> 00:17:29,930
So the double equal sign is this something is something true or false you know.

299
00:17:29,970 --> 00:17:32,620
Or is this equal to that it's going to give you a boolean value.

300
00:17:32,700 --> 00:17:40,590
So if random number modulo or remainder operator two equals zero OK you know will print.

301
00:17:40,620 --> 00:17:43,340
This is an even number.

302
00:17:43,980 --> 00:17:45,230
All right.

303
00:17:45,300 --> 00:17:50,950
Else this is an odd number.

304
00:17:51,700 --> 00:17:52,510
OK.

305
00:17:53,020 --> 00:17:54,240
And so look it's printing up.

306
00:17:54,230 --> 00:17:57,560
This is an odd number but what if we turn this to 12.

307
00:17:57,620 --> 00:17:58,160
OK.

308
00:17:58,260 --> 00:17:59,400
So this is an even number.

309
00:17:59,400 --> 00:18:03,740
So this is something that is very commonly used to determine whether numbers are even or odd.

310
00:18:03,750 --> 00:18:04,640
Is this remainder.

311
00:18:04,650 --> 00:18:05,420
Operator.

312
00:18:05,490 --> 00:18:07,500
So you've done some basic arithmetic.

313
00:18:07,530 --> 00:18:11,470
We've talked about different types here like and double and low.

314
00:18:11,520 --> 00:18:15,380
You can use negative numbers you can use positive numbers.

315
00:18:15,480 --> 00:18:17,320
You can do all kinds of fun things.

316
00:18:17,320 --> 00:18:18,610
All right.

317
00:18:18,690 --> 00:18:25,280
And by the way this right here this is a very operator kind of like what we've talked about in the past.

318
00:18:25,410 --> 00:18:28,640
It's operating on one target here making a negative number here.

319
00:18:28,710 --> 00:18:32,510
Just so you know we'll well tip and trick right there.

320
00:18:32,700 --> 00:18:37,110
And so don't worry too much about the ifs analysis you don't understand that just yet or the string

321
00:18:37,200 --> 00:18:42,330
into position that we used here the point of this lesson is to talk about numbers you can do math operations

322
00:18:42,420 --> 00:18:48,510
and of course order of operations are all followed in swift as well as most other programming languages

323
00:18:48,520 --> 00:18:51,420
so I can save our results.

324
00:18:51,420 --> 00:18:54,350
Two equals let's say 15 times.

325
00:18:54,360 --> 00:18:58,670
Five plus seven divided by three.

326
00:18:58,860 --> 00:18:59,170
All right.

327
00:18:59,220 --> 00:19:06,300
And if I want a five and seven to be done first and then I wanted the result of this to be done next

328
00:19:08,100 --> 00:19:08,910
I could do something like that.

329
00:19:08,910 --> 00:19:16,140
So just like you do in math like in high school the order of operations you know still applies the same

330
00:19:16,140 --> 00:19:19,020
that you would do in math in high school and you can use parentheses just like you would do in high

331
00:19:19,020 --> 00:19:23,180
school math to get the results that you are looking for.

332
00:19:23,190 --> 00:19:24,860
And again this is very foundational.

333
00:19:24,860 --> 00:19:30,180
Every app you've ever used uses math like this when you're swiping your card at a bank and it wants

334
00:19:30,180 --> 00:19:35,210
to deduct money it's got to use math to take money out of your bank account things like that.

335
00:19:35,280 --> 00:19:41,000
So you have now used a basic foundational thing that you can use for the rest of your life as a programmer

336
00:19:41,130 --> 00:19:43,210
and in every house that you'll ever build.

337
00:19:43,690 --> 00:19:44,880
So that's it.

338
00:19:44,880 --> 00:19:48,320
Numbers mark up slopes dot com.

339
00:19:48,350 --> 00:19:48,980
See you next.

