Let's briefly review some of the commonly used methods in the math class you may not use math class 2
as frequently as a string class but still it is something that you might use from time to time. 3
So it would be worthwhile to check out some of its methods. 4
We also know that math class has only static methods and it is also known intangible as it has a private 5
constructor. 6
So let's go ahead and look at the math class. 7
One of the common used matters is that know the method and as the name suggests it basically didn't 8
set a random number between 0 and 1. 9
Here one is exclusive. 10
And so the method will never return a value of one and the value return is a double value. 11
You can also see an example here. 12
Here we want to generate a random integer between zero and five. 13
So you would multiply Matt not random but w W5 and then caused the result to an end. 14
For example if the method returns a random number zero point nine. 15
Then on Monday playing with file the value would be 4.5. 16
But when cast is applied the value 4.5 gets truncated before this recall for more typecasting discussion 17
that when we cast a flawed r w an integer it will all this truncate the number. 18
So in this case we wanted a random number between zero and five. 19
And if you want a random number between 0 and then we would simply multiply Mad Dog random the WGAN 20
. 21
We will also use this method quite a bit in our project that we will implement after completing object 22
oriented concepts. 23
Next is the matter ABS which is an overloaded method that returns the absolute value of the argument 24
. 25
So if the argument is minus 240 as shown here then it would read in a positive to 40. 26
Of course if the argument is already positive do then the return value would be same as the input argument 27
. 28
Next is that Rawn method as the name suggests. 29
It basically advanced the input argument to the nearest long r and depending on the data type of the 30
argument. 31
So if argument is a double value then it gets thrown into the nearest long rally. 32
For example here twenty four point eight is a double value and so it gets rounded to the nearest long 33
value with just one defined. 34
Hello what if argument is flawed then it gets thrown out the nearest interview. 35
For example are twenty before want to file is a float value and it gets thrown into the nearest And 36
with just one before. 37
Basically double the 64 bits and so long as return as it is also 64 bits. 38
Same happens with float. 39
And both of which are represented in 32 bits. 40
Next is the silly method it returns the smallest double that is greater than or equal to the argument 41
. 42
Another one should be equal to an integer. 43
Here in this example. 44
Input argument is 20.00 on and so the seen method would require the double value 21 so can do it. 45
Here is the smallest double value that is greater than can be Point 1 undergoes equals an integer. 46
Can you guess what it would get done if the argument is a double point B. 47
It would be current itself as the definition is greater than or equal to the argument should be equal 48
to an integer 2. 49
OK next is the floor method which is opposite of sea floor it does the largest double. 50
That is less than not equal to the argument. 51
And it should also be equal to an integer. 52
You can also see an example here. 53
So both C and floor return a double value. 54
Well-drawn method returns a long road and none of them and their names reflect what they are doing. 55
If it is seen it means like a ceiling on say greater than or equal to will you believe it can. 56
Well for float it means like bottom on a smaller or equal two value will be returned. 57
Put it on. 58
It will simply be rounded to the nearest integer value depending on the argument that is it can be either 59
a value that is greater than the argument R.W. smaller than the argument next the overloaded min and 60
max metrics which stick to arguments as the names imply dissimulated and minimum or maximum of the two 61
numbers. 62
Next a square root and square root of the argument as a double value. 63
But if argument is something called nine or a negative number then a 9 would be returned. 64
Nan stands for Not the number. 65
And it implies something that is undefined or in other words meaningless. 66
It is produced if a floating point operation has some input parameters which cause the operation to 67
produce an undefined result in the case of square root. 68
It can be a negative argument which is basically meaningless because it's a matter to return a man. 69
Similarly if you do get a double value zero with another double value zero then we get a Nanna's output 70
. 71
Similarly there is a method for finding cube root and also there are few other commonly used matters 72
related to logarithmic and parametric functions. 73
So I think we covered some very common to use my dad's knowledge just very quickly. 74
Yes some of them are there to be reviewed in my Eclipse already. 75
OK let's just look is there and that would be generated. 76
OK so let's have this statement and let's have a double zero which is divided by double zero discharge 77
under demand. 78
We discussed this earlier. 79
So as you can see when I run it it prints none. 80
So this expression is generating it. 81
Man next Let's try my dark square root and for this effect give a negative number. 82
It would also generate and 9. 83
So an ironic X is not OK so it needs to be a positive value. 84
Next let's test a random method. 85
So let's gaster to and let's just try the same method. 86
Same example that we have seen 87
math dark ride numbers generates a number between 0 and 1. 88
Since we want number between 0 and 5 so be multiplied with 5 and when we run it. 89
So it's printing for let me run it once again. 90
This time it is under-10 0. 91
What I need one more time. 92
It's generating 3. 93
So that's the random number generator. 94
Next let's try wrong. 95
So let's say math wrong let's say twenty one point four 9 9 9. 96
And since this is our diabolical Jondrette the nearest long and then nearest long will be 21. 97
OK but if we make it one day 1.5 it should pretend to Google only to 22 and you can see it here. 98
So that's what we have. 99
Next let's try seal. 100
So Matt Dotsie just know that all of these are static methods and so we are just accessing using the 101
Glasman. 102
So let's say twenty one point one. 103
So this should generate a double 22 right. 104
Since it's a sealed function. 105
Now if we make it floor it will be 21. 106
So you can see Prince 21 next. 107
Let's just try the max function not Max and that is also a min. 108
But let's just try. 109
Mad Max defier. 110
So this should bring to an defier. 111
Here you go. 112
So that's about it. 113
So just go ahead and explode the Djala API. 114
I look at the math class. 115
It has many other methods so just go ahead and familiarize yourself with that and are some of them. 116
And that's about it. 117
And thank you