AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Bits in a byte1/2/2023 ![]() ![]() (But just in case you need a little help, I’ve included the powers of two in my examples below.) Converting into binary Remember in elementary school when we all had to learn our multiplication tables? And then remember in middle school when we started learning exponents and realized how useful those multiplication tables were? Well, get ready to re-realize that once again! I’ve been practicing converting to and from binary a lot over the past week and I’ve realized that the most important thing you can do when it comes to learning binary is brush up on your powers of two. We’ll keep it simple and focus on converting between base 10 numbers (integers) to binary. While it’s not important to know all the layers, I do think that there’s value in knowing a little bit about how that conversion works. ![]() This happens through several layers of abstraction, and we won’t get into all of them. And yet none of us type binary into the keyboard! This would lead us to believe that, somehow, what we type into our machines gets converted (compiled) down to binary. It should become a little bit more obvious later). (Pssst - there’s a pattern in the number of possible permutations/combinations per digit! But if you don’t see it yet, don’t worry. And if we continue to do that, we’ll see that the first 10 numbers in binary like this:Ġ 1 10 1011 1100 1101 1110 1111 Then we increment the first place again: 11. To represent the number 2, we reset the first place to 0 and add another digit to the left: 10. The same logic applies to counting in binary. We do this until we’ve reached the numbers between 90–99, and then we add another place: the hundreds place. When we’ve gone through all the possibilities between 10–19, we reset the units place to 0, and increment the tens place to the number 2. When we get to the number 9, what do we do? We reset the units to start again with the number 0, and increment our tens place to the number 1. Well, let’s think about what we do in base 10. But when we get to the number 2, how do you keep counting?! In the example to the left, we can see that we start off counting the same way we do in base 10. Okay, so, if binary has just two digits, how do you count past…two? Binary counting The binary number system that is used in computers today was created by Gottfried Wilhelm Leibniz in 1679, but this way of counting has a much longer history that dates back to the ancient Egyptians. The binary number system hinges on a simple idea that, instead of counting with 10 digits - the way that we learned to do in kindergarten - you can count with just two digits. ![]() Those ones and zeros that computers are made up of? Those are based on a type of number system called binary. Let’s start by giving our problem a name. It’s definitely a bit more complicated than that, but it’s not so complicated that we can’t understand it! #Bits in a byte codeIt was only after I learned to code and started programming professionally that I realized what that really meant. This was one of the few things I knew about computers before I got into software: it’s all just ones and zeros. If you work with computers (or even if you don’t!), there’s a good chance that you’ve heard people talk about computers as just “a bunch of ones and zeros”. ![]()
0 Comments
Read More
Leave a Reply. |