‫Welcome back.
‫And this video, we are going to cover math.
‫So the math class pretty much.
‫Not just math, the subject in school, but the math class.
‫And therefore and therefore, I created a new project here and I'm going to console right line in here
‫to keep the program program open.
‫You can alternatively always start with control f five if you want to keep the console open without
‫this console read line line.
‫But anyways, let's go ahead and use math.
‫In order to use math, we need to do the following.
‫We need to simply type in math.
‫And then you can see there is system dot math, a class which provides constants and static methods
‫for tried economic, logarithmic and other common mathematical functions.
‫So you don't need to do loads of the stuff on your own.
‫You don't need to write methods for many things.
‫They are there already.
‫So whenever you want, for example, to seal something.
‫So if you want to round up, you can do the following.
‫You can just say ceiling and I'm going to use math dot ceiling and then you simply need to enter the
‫decimal.
‫So let's say I want to seal 15.3, then that's how I do it.
‫So let's see what the result is and we'll see ceiling 16.
‫So even if 15.3 usually wouldn't be sealed because it's below 0.5, it still is being sealed here.
‫So that's how you can round up a value.
‫All right.
‫You get the next full number with the ceiling method.
‫So this math class has a method called ceiling.
‫But in general, if you enter math, you can see there are plenty of methods, there are constants and
‫methods.
‫So you can get the sinner's or sinus you can get.
‫Exponentials, maximum minimum values and so forth.
‫And then you see here the constants are E and PI.
‫So those two constants are available and those are the different methods that we have.
‫So let's look at some other methods.
‫Let's look at floor.
‫So round down or floor or something and that's done with math dot flor.
‫And if we flor 15.3 again, this time we get 15.
‫So we get the next lower full number or whole number.
‫So 15 is a whole number.
‫Then we have some other ones.
‫Let's say I want to get the lower of two values.
‫So I have two values, let's say number one, which is 13 and number two, which is nine.
‫Now I would like to get the lower of the two here.
‫It's easier and obvious.
‫We can see, okay, nine is lower than 13.
‫We don't need the method for that.
‫But if the input is something else, so if the user can do the input or if it's from a database or something
‫like that, then this method could be useful because we always will get the lower of the two values.
‫So let's say lower of num one which is this.
‫And number two, which is that is and that's this.
‫So what is it, number one num two.
‫And finally we use math dot min.
‫So there is this method called min returns the smaller of two eight bit unsigned integers.
‫So here it only accepts integers and here I say num one and num two because these are the two variables
‫that I'm looking at.
‫All right.
‫Now, what will it return?
‫Well, you guessed it, it will return nine.
‫So it says lower of nine, one is 13 and num two, nine is nine.
‫Now, you can do the opposite of course for the higher value.
‫So see w higher of num one
‫and number two is num one num two math and now we use the max method num one num two and that's it.
‫So now let's check it out.
‫This time we should get 13.
‫So the higher of 13 and num 129 is 13.
‫All right, that's good.
‫But there are some more things like by the power.
‫So for example, three, two, the power of five is and what is it.
‫It's math dot pow.
‫So the power method returns a specified number.
‫Race to the specified power.
‫So three to the power of five, three and five.
‫Now.
‫Let's check it out.
‫And we are we get 243.
‫Then if you just want to use pie, which is very common, pie is
‫and math pie like that.
‫So that's what pie is.
‫And you will see the precision as well.
‫So there is, of course, only a specific precision, and that's the precision of a of a double.
‫So I can see it's one, two, three, six, nine, 12 and 11.
‫So it's 12 digits here in total.
‫Then if you want to have the square root, the square root of 25 is and then you use the math as Q are
‫DT method.
‫So sqrt gives you the square root of a double value.
‫So it doesn't have to be a whole number, it can be a double value.
‫So in my case, it's an integer with the value of 25.
‫So the square root of 25 is five.
‫Then if you want to have the absolute number, which means it's always going to be positive no matter
‫what.
‫Then you use the ABS method, so CW always positive is and then you enter math dot abs.
‫So returns the absolute value of a decimal number, a number that is greater than or equal to decimal
‫value, but less than or equal to decimal max value.
‫So we can use pretty much the whole decimal range.
‫And here if I enter something like -25, then that will return 25 because it's always positive.
‫So always positive is 25.
‫Next.
‫There is one more thing that I want to show you and that's using coziness.
‫So CW codes of one is and that's math dot co's and here you can enter a double.
‫I'm just going to enter one.
‫Let's check it out that we are coding of inverse of one is 0.5, four and so forth.
‫Of course, there are many more methods and I'm not going to cover all of them, of course.
‫But you can simply check them out.
‫You can see you can use the logarithm, then exponent or exponential and so forth.
‫So there's plenty even coziness, hyperbolic costs or hyperbolic costs, a sinus, a coziness and so
‫forth.
‫So there's plenty of cool methods and whenever you work with maths, just consider using the math class
‫because well, it might help you out.
‫All right.
‫So see you in the next video.