1
00:00:05,970 --> 00:00:09,020
Everybody what's going on this is Caleb with Dev's Loeb's dotcom.

2
00:00:09,030 --> 00:00:14,920
And in this video we're going to be talking about variables and their storage capacity in programming.

3
00:00:15,000 --> 00:00:17,150
Memory management is super important.

4
00:00:17,340 --> 00:00:23,430
Thankfully most of this is done for us which is really cool but there are circumstances where we might

5
00:00:23,430 --> 00:00:27,630
have a need for a specific type or size of data.

6
00:00:27,770 --> 00:00:32,340
OK so that's where this storage capacity and variable size is going to come into play.

7
00:00:32,340 --> 00:00:33,980
So let's dive right in.

8
00:00:34,080 --> 00:00:38,000
The first thing we need to consider is device architecture.

9
00:00:38,010 --> 00:00:38,490
Okay.

10
00:00:38,730 --> 00:00:45,480
Now that means does the you have an 8 16 32 or 64 bit processor.

11
00:00:45,480 --> 00:00:47,250
I'm sure you've heard those words before.

12
00:00:47,350 --> 00:00:50,790
Like you know your computer might have a 64 bit processor.

13
00:00:50,790 --> 00:00:56,460
A basic understanding of binary will help us understand the capacity of variables for these different

14
00:00:56,700 --> 00:00:57,690
architectures.

15
00:00:57,690 --> 00:00:58,340
OK.

16
00:00:58,710 --> 00:01:06,540
Now in binary bytes are arranged in 8 bit chunks with the value of each bit being worth double its neighbor

17
00:01:06,540 --> 00:01:08,530
going from right to left.

18
00:01:08,660 --> 00:01:15,950
K. now a processor that can handle 8 bit chunks of data is called well an 8 bit processor.

19
00:01:16,040 --> 00:01:16,310
Ok.

20
00:01:16,310 --> 00:01:23,760
Popular computers that utilize this long long time ago were the apple one the apple to the Atari 2600

21
00:01:23,790 --> 00:01:27,790
and even yes the Nintendo Entertainment System.

22
00:01:27,840 --> 00:01:33,100
So it's it's been around it's been a popular thing now 16 bit processors.

23
00:01:33,240 --> 00:01:39,330
They came along and they were faster and able to handle bigger chunks of data at the same time double

24
00:01:39,330 --> 00:01:41,240
the capacity of its predecessor.

25
00:01:41,370 --> 00:01:43,960
Pretty impressive for a long time.

26
00:01:44,010 --> 00:01:51,180
Our computers and devices ran on 32 bit processors but eventually they made a jump up to 64 bits which

27
00:01:51,180 --> 00:01:57,420
is what most computers nowadays utilize and devices as well like my iPhone for instance has a 64 bit

28
00:01:57,420 --> 00:01:58,710
processor.

29
00:01:58,710 --> 00:02:04,740
Now when you start thinking about the capacity of an 8 bit system that means that the largest possible

30
00:02:04,740 --> 00:02:10,630
value for a particular chunk of information is 255.

31
00:02:10,890 --> 00:02:15,480
As we add up all the values of the 8 channels we get 255.

32
00:02:15,480 --> 00:02:22,680
However when we double the capacity to 16 bits we're suddenly able to store up to sixty five thousand

33
00:02:22,740 --> 00:02:29,100
five hundred thirty four 32 bits gets us four billion two hundred ninety four million nine hundred sixty

34
00:02:29,100 --> 00:02:31,740
seven thousand two hundred ninety four.

35
00:02:31,800 --> 00:02:39,370
So you can see the exponential growth here and 64 bits gets us up to over 18 quadrillion.

36
00:02:39,390 --> 00:02:44,190
It's insane how big the capacity becomes with 64 bits.

37
00:02:44,190 --> 00:02:51,540
So now that we know the size of the chunks of data that RCP can handle Let's talk about variables in

38
00:02:51,540 --> 00:02:58,070
programming a variable is a value that is stored in memory and used and modified by a program.

39
00:02:58,170 --> 00:03:02,120
There are different types of variables as well integer values.

40
00:03:02,160 --> 00:03:05,850
Decimal values text values and boolean values like.

41
00:03:05,850 --> 00:03:07,400
True or false.

42
00:03:07,410 --> 00:03:14,510
So as an example let's look at some very specific integer types unsigned and signed integers.

43
00:03:14,640 --> 00:03:21,540
So in many languages you can use unsigned unsigned integers unsigned just means that a value can either

44
00:03:21,540 --> 00:03:29,940
be positive or 0 signed means that the value can be positive negative or zero unsigned integers have

45
00:03:29,940 --> 00:03:39,020
a storage capacity of 8 16 32 and 64 bits you can make an unsigned integer with any of those bit sizes.

46
00:03:39,120 --> 00:03:45,720
And believe it or not that means that for whatever size they are they can store a max value of the sum

47
00:03:45,810 --> 00:03:47,380
of their channels k.

48
00:03:47,550 --> 00:03:55,320
So basically what I mean is like an 8 bit unsigned integer can hold a value of 255 16 bit can hold sixty

49
00:03:55,320 --> 00:03:59,010
five thousand five hundred thirty four and so on.

50
00:03:59,010 --> 00:04:05,250
Just like the values we talked about before with with the processors can handle those sizes of chunks

51
00:04:05,250 --> 00:04:09,370
of data the various integers can also hold those chunks of data.

52
00:04:09,510 --> 00:04:15,140
Now a signed integer since it can be both positive or negative.

53
00:04:15,180 --> 00:04:19,140
We basically take it's total capacity and cut it in half.

54
00:04:19,140 --> 00:04:24,310
And so basically it has an equal reach for both positive and negative.

55
00:04:24,330 --> 00:04:34,530
So where a 16 bit unsigned integer can go from 0 up to five thousand a signed 16 bit integer can go

56
00:04:34,590 --> 00:04:40,060
all the way up to thirty two thousand seven hundred sixty seven and all the way down to negative thirty

57
00:04:40,060 --> 00:04:41,720
two thousand seven hundred sixty seven.

58
00:04:41,730 --> 00:04:48,310
So we just cut that number in half decimal values can be represented by either a double or a float.

59
00:04:48,390 --> 00:04:55,820
In most programming languages and usually a double has a 64 bit capacity and is more precise you know

60
00:04:55,830 --> 00:04:58,290
more data equals more precision.

61
00:04:58,290 --> 00:05:05,640
A float has a 32 bit capacity and both both are accurate but a float has slightly less that because

62
00:05:05,640 --> 00:05:07,590
it can hold less data.

63
00:05:07,590 --> 00:05:14,060
Now let's move on to another type of variable called a string and a string holds text data.

64
00:05:14,130 --> 00:05:14,600
OK.

65
00:05:14,850 --> 00:05:23,370
And depending on the architecture of your device it can hold either 32 bits or 64 bits worth of data.

66
00:05:23,370 --> 00:05:25,170
That's a lot of data for one string.

67
00:05:25,170 --> 00:05:28,050
So that's actually way more than you would usually ever use.

68
00:05:28,050 --> 00:05:32,700
Most strings are going to be nowhere near that that large and they shouldn't be because that's just

69
00:05:32,940 --> 00:05:33,660
ridiculous.

70
00:05:33,660 --> 00:05:38,640
You should probably find another way to show text data if you are trying to hold Sixty-Four entire bits

71
00:05:38,730 --> 00:05:39,760
of information.

72
00:05:39,840 --> 00:05:40,600
That's insane.

73
00:05:40,740 --> 00:05:42,720
So anyway it's cool to know.

74
00:05:42,720 --> 00:05:50,430
So to recap we talked about processors and the different sized chunks that they can handle in data depending

75
00:05:50,490 --> 00:05:51,670
on their architecture.

76
00:05:51,720 --> 00:05:55,770
8 bits 16 bits 32 bits or 64 bits.

77
00:05:55,770 --> 00:06:01,980
We also talked about variables and their various size capacities like unsigned unsigned integers like

78
00:06:01,980 --> 00:06:04,100
strings like doubles and floats.

79
00:06:04,320 --> 00:06:07,220
And we even talked about the various variable types.

80
00:06:07,230 --> 00:06:08,480
Right we talked about what they are.

81
00:06:08,490 --> 00:06:13,620
String is for holding text a boolean is for holding a true or false value.

82
00:06:13,620 --> 00:06:20,450
A double is for holding a decimal value with with a greater accuracy than its neighbor the float.

83
00:06:20,580 --> 00:06:22,980
We talked about all of that amazing work.

84
00:06:22,980 --> 00:06:25,880
And let's head over to the next video and let's continue learning.

85
00:06:25,890 --> 00:06:28,060
This is Caleb with devs Loeb's dotcom.
