Everybody what's going on this is Caleb with Dev's Loeb's dotcom.
And in this video we're going to be talking about variables and their storage capacity in programming.
Memory management is super important.
Thankfully most of this is done for us which is really cool but there are circumstances where we might
have a need for a specific type or size of data.
OK so that's where this storage capacity and variable size is going to come into play.
So let's dive right in.
The first thing we need to consider is device architecture.
Okay.
Now that means does the you have an 8 16 32 or 64 bit processor.
I'm sure you've heard those words before.
Like you know your computer might have a 64 bit processor.
A basic understanding of binary will help us understand the capacity of variables for these different
architectures.
OK.
Now in binary bytes are arranged in 8 bit chunks with the value of each bit being worth double its neighbor
going from right to left.
K. now a processor that can handle 8 bit chunks of data is called well an 8 bit processor.
Ok.
Popular computers that utilize this long long time ago were the apple one the apple to the Atari 2600
and even yes the Nintendo Entertainment System.
So it's it's been around it's been a popular thing now 16 bit processors.
They came along and they were faster and able to handle bigger chunks of data at the same time double
the capacity of its predecessor.
Pretty impressive for a long time.
Our computers and devices ran on 32 bit processors but eventually they made a jump up to 64 bits which
is what most computers nowadays utilize and devices as well like my iPhone for instance has a 64 bit
processor.
Now when you start thinking about the capacity of an 8 bit system that means that the largest possible
value for a particular chunk of information is 255.
As we add up all the values of the 8 channels we get 255.
However when we double the capacity to 16 bits we're suddenly able to store up to sixty five thousand
five hundred thirty four 32 bits gets us four billion two hundred ninety four million nine hundred sixty
seven thousand two hundred ninety four.
So you can see the exponential growth here and 64 bits gets us up to over 18 quadrillion.
It's insane how big the capacity becomes with 64 bits.
So now that we know the size of the chunks of data that RCP can handle Let's talk about variables in
programming a variable is a value that is stored in memory and used and modified by a program.
There are different types of variables as well integer values.
Decimal values text values and boolean values like.
True or false.
So as an example let's look at some very specific integer types unsigned and signed integers.
So in many languages you can use unsigned unsigned integers unsigned just means that a value can either
be positive or 0 signed means that the value can be positive negative or zero unsigned integers have
a storage capacity of 8 16 32 and 64 bits you can make an unsigned integer with any of those bit sizes.
And believe it or not that means that for whatever size they are they can store a max value of the sum
of their channels k.
So basically what I mean is like an 8 bit unsigned integer can hold a value of 255 16 bit can hold sixty
five thousand five hundred thirty four and so on.
Just like the values we talked about before with with the processors can handle those sizes of chunks
of data the various integers can also hold those chunks of data.
Now a signed integer since it can be both positive or negative.
We basically take it's total capacity and cut it in half.
And so basically it has an equal reach for both positive and negative.
So where a 16 bit unsigned integer can go from 0 up to five thousand a signed 16 bit integer can go
all the way up to thirty two thousand seven hundred sixty seven and all the way down to negative thirty
two thousand seven hundred sixty seven.
So we just cut that number in half decimal values can be represented by either a double or a float.
In most programming languages and usually a double has a 64 bit capacity and is more precise you know
more data equals more precision.
A float has a 32 bit capacity and both both are accurate but a float has slightly less that because
it can hold less data.
Now let's move on to another type of variable called a string and a string holds text data.
OK.
And depending on the architecture of your device it can hold either 32 bits or 64 bits worth of data.
That's a lot of data for one string.
So that's actually way more than you would usually ever use.
Most strings are going to be nowhere near that that large and they shouldn't be because that's just
ridiculous.
You should probably find another way to show text data if you are trying to hold Sixty-Four entire bits
of information.
That's insane.
So anyway it's cool to know.
So to recap we talked about processors and the different sized chunks that they can handle in data depending
on their architecture.
8 bits 16 bits 32 bits or 64 bits.
We also talked about variables and their various size capacities like unsigned unsigned integers like
strings like doubles and floats.
And we even talked about the various variable types.
Right we talked about what they are.
String is for holding text a boolean is for holding a true or false value.
A double is for holding a decimal value with with a greater accuracy than its neighbor the float.
We talked about all of that amazing work.
And let's head over to the next video and let's continue learning.
This is Caleb with devs Loeb's dotcom.