In this lecture, I would like to introduce you primitives.
First, we will go through the list of the primitives and what values we can store in them.
Next, we will go to the website where I will show you where you can use these primitives.
Then we will do a coding practice based on the website.
And last you will see how to convert one data type into another one and what pitfalls it might have.
OK, let's do it.
So we have four groups of primitives, whole numbers, floating point numbers, boolean and character.
Whole numbers are byte, short end and long byte can store values from minus one hundred and twenty
eight to one hundred and twenty seven short from almost negative thirty three thousand to almost thirty
three thousand and can store a little bit more than two billion in positive and negative and long can
store a massive number.
The most commonly used is Int and the rest of them are barely used.
But if you are restricted on memory, you use byte short if it's necessary and if you need to store
a huge number used long.
OK, let's move on to floating point data types.
There are float and double that you can use as variable data type.
The difference between the two is that float can be precise until six to seven decimal digits and double
until 15 decimal digits.
Here, double is the more commonly used.
There are two other primitive data types, boolean and character here.
Char Boolean is probably the most commonly used data type of all.
It can have two values, true or false.
The other type is char, which can store one single character or an escort character.
Don't worry if you don't know what Askey means, I will tell you what it is and how to use it later.
OK, now let's move on to the website I mentioned before.
OK, so the website we are going to use as an example is Mobileye DC and here are the details of a damaged
2018 Dodge Challenger SRT.
And I'm going to show you what data types can be used to store these values.
I'm going to think universal, so I will choose data types based on the idea that it could be any other
car.
OK, just a side note.
Before we started, price is a whole number and a coma here is just a separator.
While in case of fuel consumption, it is a decimal point and points just separators for thousands.
OK, let's start with numbers.
So the price of this car can be stored in a short.
OK, but what happens if the car is more expensive?
For example, it is a Ferrari, then we need an integer.
Do we need a long for this?
No, I think it's very unlikely that a car can be more expensive than two billion if the prices are
stored in euros.
The next one is the mileage.
Same situation here.
Short is not enough for this, but an integer is good.
The next one is power.
OK, so here is a time for using short byte.
Would be too small for these numbers.
An integer is an overkill because it is pretty unlikely to have a car with more than 32000 horsepower
or kilowatt cubic capacity can be stored in a short ASBA.
OK, moving on to fuel consumption here.
Float is far more than enough to do the job.
Even if you are working in a lab, you don't need to know more than six to seven digits.
If they would need more precision, they would use double for these next kommission.
I think short is enough number of seats.
While it is a tough one for a bus, it may need to be a short, but I think byte is enough.
Count is an absolute by type emissions sticker, and number of vehicle owners can be stored in a bite
as well.
It is very unlikely that the number of owners will be over 100 and 27 here.
First, registration and age.
You are dates.
We don't deal with them now.
So two data types are not used here.
Boolean and Char, as you can see, it is a damaged car and there might be a variable called is damaged
and the value of that variable is true for this car.
And if that is true, the damaged accident damaged vehicle text appears.
But if it's not true, the text doesn't show up.
And last Char, to be honest, we don't really use this the last time I use this, well, it was 10
years ago before this recording, but I think you must know what it can be used for.
So, for example, emissions sticker may have other values like A, B or C, four different emission
levels.
So that can be one option to use char.
The rest of the site is stored in string.
We will cover that later.
Or static HTML text, which is not stored or used, but it is simply displayed.
All right.
That's all about the website.
Let's do some practice.