Okay.
So let's talk about the numbers in PHP.
So we've already covered that plenty of times.
But let's have a reminder.
So we have integers.
And we've got floating point numbers like this p number right here.
Now you can cast strings to integers by using the int operator like that.
And also you can cast floating point numbers to integers.
Like this.
Now let's all vardump this to see what are the values.
So integer and float.
This should be obvious and string to integer and float to integer.
Let's see what's the effect.
Let's run numbers.
PHP.
There it is.
So next up there are some arithmetic Relations.
So I don't think there is much point in showing them because they are pretty basic.
Like you've got addition, subtraction, you can multiply or divide values, but an interesting one
is modulus, which is the remainder of a division by a number.
And this is often used to find odd and even numbers.
Let's say you've got seven and you just do modulo by two.
And if the remainder is one, this means it is an odd number, and if the remainder is zero, this means
it is an even number.
Okay.
And something that's really interesting and useful with numbers is all the mathematical operations.
So for example rounding of the numbers.
So I promised you that before, and we haven't really done that other than actually casting a float
number to an integer, which in this case 399 always casts to three.
That might not be what you really want, especially if you, let's say, want to be fair.
And let's assume this is an average rating of a book or movie, or someone grades 399 is really close
to four, so it should be rounded up to four, not rounded down to three.
And there are different functions that just do it differently.
So first round with three seven.
And then let's do round with 3.4.
Let's run this.
So as you see the 3.7 rounds to four.
But if it is Below three and a half, it rounds to three.
So this is how round works.
But there also is a floor function.
Let's run it for 3.8.
And it will also always round down.
Then there is a scale function.
Let's run it on 3.1.
This would always round up.
Next up there are some functions like minimum or maximum.
So it basically will find either the minimum or the maximum functions from those given.
This is often very useful especially for algorithms as you see.
Minimum is one.
Maximum is seven which makes perfect sense.
Then randomizing and generating a random number.
So this would give you a random number every single time we've got two, then we've got five, etc.
and an absolute function abs.
And this just gives you an absolute value of a number.
So in case of minus five this would be five.
Then there is the number formatting.
So let's come up with a number maybe something like this.
And then you might want to format it in a specific way.
So there is the number format function to which you can pass the number.
Then you can choose how many decimals you would like.
So it defaults to zero.
So maybe if this has more I can just select that.
I'd like two decimals.
And this really makes sense for the currencies and all the numbers that needs to have at most two decimals,
because more decimals would make zero sense for such numbers.
And then you have decimal separator.
By default it's dot but it differs across countries.
So you might use a comma.
And then the final one is thousands separator.
So there are countries which don't use any thousands separator.
And there are countries which do.
So maybe let's use a dot for the floating point number separation.
And.
This is how this number right here was formatted.