Hello and welcome to another episode and the Godot basics took torrio series. In this episode we will be taking a look at bits and bytes bits and bytes are the core of the computer universe. We use bits and bytes to describe the size of our hard drives our Ram even our music and text files and there's much much more to it than what I've listed. But again we use bits and bytes as measurement more specifically measurement of data now so far as we've grown up.
We are accustomed to the base 10 numbering system the base 10 numbering system being values ranging from zero to 9 for each digit placeholder or rather each position in the digit. So for example we have two thousand. We can break this down into two times 1000 and we can shorthand it by saying two times tend to the power of three. Just a quick refresher. However computers do not use the base 10 numbering system. Instead computers use the base to numbering system also referred to as the binary system. The
The reason why computers started and ended up using base to numbering system is because it's cheap efficient and electrical current friendly in computers. We use the word bit to describe the smallest unit of storage a bit is either 1 or zero one can be referred to as being on and zero can be referred to as being off. Now thankfully for us we will never see a bit by itself in the computer world. Bits are usually bundled together in groups of eight.
Now a group of eight bits is also referred to as one byte with one byte we have 256 possible values. These values of course range from zero through two hundred and fifty five. Keep in mind zero through two hundred fifty five is written in The Ten base system. However when dealing with the two base system you'll notice that we usually line our zeros from right to left. Just like we do in the ten base system however because in computers we allocate one byte or in multiples of bytes you will normally see in articles the bits being represented in groups of eight.
Now here is a table of what the binary digits look like and how we can convert it into the base 10 numbering system. So when everything in binary is 0 we say that it can be converted into the base 10 numbers 0. Now when the first digit in the binary system is 1 we say that that has a value of 1 when the second digit in the binary system is 1. We say that the number has the value of 2 as a matter of fact. Let me go ahead and change this table.
And so we can have an easier time seeing which numbers are 1 so again 0 0 1 is 1 1 0 is 2 1 1 is 3 1 0 0 is 4 1 0 1 is 5 1 1 0 6. Now if this is a little complicated or a little confusing that's OK since you're getting started you don't have to memorize every single possible combination in relation to its 10 base numbering system. However. You should have a basic understanding of how to achieve or rather how to translate
A two based numbering system into a ten base numbering system. So again one. Byte is equal to a bit. We have two hundred and fifty six possible values the 256 possible values is a range from zero to two hundred and fifty five and each position in the two base numbering system has a value the first digit can either be 0 or 1 the second digit can either be 0 or two the third digit can either be 0 or for the fourth digit can be 0 or 8 and so forth.
So each digit in the 2 base numbering system is basically two to the power of x two to the power of zero two to the power of one two to the power of two and so forth. Now let's get started. If everything zero. We obviously have a value of 0 and the 10 base numbering system if we have a value of 1 in the two base numbering system that is a value of 1 in the 10 base numbering system. Now if we have a value of 1 0 0 0 0 0 0 1 in the 2 base numbering system.
Keep in mind that the 8 digit because it's on that means we have one hundred twenty eight. And because the first digit is on we have a value of 1 we can say 120 plus 1. And that means that when our 2 base numbering system is converted into a 10 base numbering system that value is 1 twenty. And if we have a value of 1 0 0 0 0 1 0 1 when we convert that we can add 100 8 by 4 by one. And so again one twenty eight plus four plus one and that equals to one hundred thirty three.
So you can start seeing the conversion of taking something in to base numbering system into the ten base numbering system. Now I want you to notice something at the top. We have our two base numbering system are to base numbering system can either be 1 or 0. If it's 0 we do not add if it's 1 we do add. However notice that the number underneath is the 10 base numbering system representation of our 2 base numbering system starting from the right which is 1 ending on the left which is one hundred twenty eight.
And when we do the conversion what you'll notice is that really it's just adding values of two to the power of X X being the position of our digit in the 2 base numbering system starting from 0. So 2 to the power of 0 is 1 2 to the power of 1 is to 2 to the power of 2 is for two to the power of three is eight. And it continues on until we hit 128. And so another way of doing your mathematics would be through the power of two System 1 multiplied by 2 to the power of 7 plus 1 multiplied by 2 to the power of two plus one multiplied by 2 to the power of 0 which is 133.
Now why should you understand bits and bytes. Well for one thing bits and bytes are used to hold your data. This includes integers and more importantly strings. Strings use the HSC to character set and that's how we are able to convert numbers into strings or characters. And lastly Godot does allow for a bit wise operations also referred to as bit manipulation. I hope I was able to introduce the concepts of two based numbering system and the conversion into 10 based numbering system.
I'm also going to post links down below or rather I'm going to post articles down below so you can learn more about bits and bytes. Thanks for subscribing and thank you for clicking the Like button and if you have any questions or comments please feel free to leave them in the comments section down below. I look forward to seeing you in the next episode. Have an amazing day