So another type of data types.
And that you can see is signed and unsigned now, signed variables can be either positive or negative
because they have one bit reserved for design.
So one of the bids out of the entire structure will be reserved for sign is the most significant bit,
and I'll show you later on.
But an unsigned data type, an unsigned variable, does not have a sign, so therefore the value that
gets stored in it is always positive.
Now, the next data type that we're going to talk about is character.
The character data type will store only individual characters.
When assigning a value to a char variable, you must use single quotes around the character like this.
And the charged data type is still a numeric type.
That means that each character will actually be stored in the computer memory as a number.
The key word for the character data type is char or care.
However you want to call it.
And here you can see how the characters get mapped to the numbers.
And this is the ASCII table.
ASCII stands for American Standard Code for information exchange, and what you want to look for is
the decimal value here.
So if you want to know what lowercase C is in decimal, it's right here.
It's ninety nine.
So for the character data type, we have unsigned and signed versions, so for unsigned char, this
is going to be the key word for it.
And this will also hold only one character at a time.
But it does occupy one bite on most computer systems.
And one by means a bit, so you can see here the lowest value that an unsigned char variable can hold
is all zeros because it doesn't have a sign, all of the bits are used for value.
And then the maximum is when all of the bids are won.
And here you can see the range, it ranges between zero and 255 inclusively.
So for signs, character data type.
This one has a sign and like I was saying before, the most significant bit is used to represent the
sign.
Now, the minimum actually this.
So this also occupies one bite in the computer memory.
So eight bits you have them represented here.
And because this has a sign, one means minus zero means plus.
So the least number that these bits can represent, together with this being a minus is the maximum
of the value.
So all of these value bits will be set to one that yields minus 128.
And then the maximum value in this case, the sign will be plus.
And then the maximum of these like value bits, which are still one, and that will be one twenty seven.
So that is the range and the the way to know if your char is signed is that there's no one sign in front
of it here.
So.
Another data type very important is an integer.
So the integer can only hold hold numbers and unsigned integers will only hold a positive whole number.
Meanwhile, signed integers can hold either a positive whole number or a negative one.
So here you can see that the unsigned integer occupies four bytes in computer memory now.
So that is 32 bits and you can see it here.
In the case that we're talking about the minimum value that an unsigned end can have.
It is all zeros because there is no sign and all of the 32 bits are used for value.
So in this case, zero is the lowest value in the range that an unsigned in can hold now for the maximum,
and they're going to be all one, and that yields four million.
Now four million two hundred ninety four million nine hundred sixty seven thousand two hundred ninety
five.
So this is the range.
And unsigned and is the key word for it.
And this unsigned INT data type can only hold all numbers in between this range right here.
No more and no negatives, for sure.
And here is an example if you want to create a variable of type unsigned int.
This is how you do it.
So far, it is signed, and now this one does have a sign.
And the most significant bit here will be the sign in the case of the minimum, because this also has
four bites, so this will be thirty two bids.
In the case of the minimum, this sign will be a minus and then we want the maximum value of the rest
of the bids, which actually are going to be all used for value, except for this one.
And that will be this number here.
And then for the maximum, we want a plus and then the maximum value we can get out of the rest of the
bits which are used for value, so that yields to this number here.
And the key word for assigned integer is int.
And this is an example of how you can create a variable of type signed end.
So another data type that I want to talk about is a float.
So a float is used to define variables that can hold real numbers of fractions, right?
Float is considered single precision because it can hold up to seven decimal places.
It still has a size of four bytes.
And this is the key word for it float.
Here's an example.
So you'll be using this if you need to store a number that has maximum seven decimal places.
Otherwise, the rest of them will just not be stored if it has, let's say, eight.
Decimal places, the number that you're trying to store, it will just be like rounded up or down,
depending on if it's five or under or five or more.
And one very important thing to mention about floating a float is that there are no unsigned floating
point data types so it can hold either negative or positive numbers.
And double is like floats bigger brother because it basically does the whole thing, but it does have
double precision.
So that means that it can hold up to 15 decimal places and it has a size of eight bytes, so it's double
in size.
Key word for this is double.
So one thing to to keep in mind here, too, is that there are no unsigned floating point data types
like for a float.
And this is still considered a floating point data type.
So double and float definitely are kind of the same thing, but more precision and one less another.
Now, with that being said, we've talked about a lot of things in this lecture, but take it all with
a grain of salt just because the sizes and ranges may be different on your operating system.
The all of the sizes that we've talked about it are actually only specific to most operating systems,
so.
What you can do to actually find your design is that your variables or your data types occupy on your
computer system is to use the C plus plus size of operator to find the size that a variable occupies
in memory.
So, for example, if we have an INT variable called value that we assign tend to here doesn't even
matter if we've assigned a value to it yet or not.
If the variable is defined, we can use this statement see out size of value to print the number of
bytes, then the variable occupies in memory so.
Hopefully, you had a lot of fun watching this, this lecture.
We did talk about quite a few things today, so let us know if you have any questions.
And see you in the next lecture.