Now, we have only used so survivors, we have only use integers for round numbers, but actually there
are more data types you can use.
So what kind of data that we will need in our program?
The first foreign numbers, we have integers.
Now, we also need let's say you want to store the value three point fourteen.
You can put that in an integer as you try to do it.
C is equal to three point fourteen.
Well, this will be truncated and the real value will be three.
OK, so how to store that?
Well, you can use the float number so you can use float data type here.
All you can use double the are roughly the same and you can store float number inside double and float
that.
So then of course you can do everything we did before.
You can do a variation like plus minus multiply divided.
You can combine variables, et cetera, et cetera.
Another common data type that would be useful for us is the Boolean so that it will be bool and then
name and a boolean can contain only two values.
True.
OK, you can see it turning blue or false, the booleans will be very useful when we try to test some
conditions, for example, when we press a button in the car.
We want to know where is the button priced or not.
And in this case, we can use a Boolean to check that either it's true, it's false.
And we are going to come back later to this when we see the conditions.
And lastly, I'm going to show you the data type string, the string with an uppercase S. And this data
type is actually not in the C and C++ language.
This is specific to Arduino.
So we string you can simply store some text.
OK, so hello, Arduino.
So when we have used that print and we've text before, actually that was a string.
So it's like we could just do string name of the viable is equal to that piece of string and then I
can print here and if you look at the same monitor, OK, and here it's interesting, we have an accurate
away because we have tried to declare two variables with the same name.
OK, this is in the same scope we're going to see later what is good.
And we have two variables with the same thing.
And this will produce an error.
So we need to change here the variable to be unique.
OK, so whenever you try to use to valuably with the same name, you will get an error.
And now let's check what we have in the sale of print online and you will see hello and know can we
are going to also practice more with strings later on in the schools.
So you have integer foreign numbers, double for float numbers, but with a Kunoth million or booleans
or true or false values and string for text.
Now, one last thing to know about all of those data type is the range of the data.
There is a limit actually to what you can store in those numbers.
OK, so far in the jungling to just come to that later, that would be interesting.
But for basically, you don't really need to worry about that.
The value you can store is almost infinite.
So no trouble about this boolean where there is no problem with it because you can just store value
that are true or false.
So there is no question about that.
And train will.
You can just do anything you want.
The problem here comes with integers.
Not an integer in order is stored in two debates.
OK, and what does it mean for you practically is that you can store any value from minus thirty two
thousand seven hundred sixty eight two plus thirty two thousand seven hundred sixty seven, if you try
to start with a value that is bigger than that.
Well, this will what we call overflow.
So let's say you want to store.
Let's make an example.
Actually, I'm going to talk thirty two thousand seven hundred sixty eight, which is just above the
limit.
And let's print a.
And you can see it's not that at all, it's minus thirty two thousand seven hundred sixty eight, which
is the other opposite.
So whenever you go below that value, you will actually come back to the maximum.
And whenever you go after that value, you will come back to the minimum.
This is what we call other flu.
And this is a pretty common area you will get in your programs if, for example, you don't understand
why you get some weird values with your integer numbers.
Well, that may be because of debt.
So when you use integer, make sure you don't use integer for high values.
So whenever you need to use something more than, let's say, 10 or 20 thousands and you are not sure
that you know the maximum, well, integer is not the best data type.
How can you fix that?
Well, you can use the data type long and a long data type is actually stored on four bytes, which
means that you can go from two billion something to minus two billion, two plus two million.
So we've long you should not have really any program.
And the way to use long is the same as integer.
So you just put any value like that.
So you declare and you initialize it.
I know if I print out here, this is four hundred thousand.
Now, we should have the correct value.
Yes, the four big integer numbers used long for smaller one use integer.
All right, so now you have a global overview of what variables and why we need them.
And just one more thing is that phone I've used later like a big to name valuables, but in any of your
program and in the following of these goals, we will use meaningful names.
It's very important.
You put meaningful names for your valuables so you understand what it's OK.
When I use a I don't know what is a OK.
If you want to store, let's say, a user age, then simply name your valuable user age.
OK, you can use the common keys.
So you start with a lowercase and then for every new word you use uppercase.
OK, with no space.
So you use this convention for reliable.
And this one for constants.
So you can know what is the difference between a valuable you can change and a constant.
So for example, you want to store a temperature.
Let's, let's double temperature.
OK, if you want to start a username then just name it.
User name, and if you want to check that, that's senseor or any component is alive, then, for example,
Boulle is alive, OK, using those variables, those names for the violence will make much more sense
in your program and it will help you and other people read your code in the future.
So to recap here, when you declare a viable in C and C++ with Arduino, you need to give it a type
and to decide which type you should think about, what kind of data you want to store.
And also, for example, when using wrong numbers, what is the maximum value you expect for the valuable?