Binary, and Analog vs Digital Tutorial
In this tutorial, we’ll take a look at the workings of computers in certain aspects, instead of programming itself! First, we’ll begin by looking at analog and digital signals, and then diving a bit more into digital signals, and discussing binary.
Analog Signals vs Digital Signals
So, analog signals was the system used back in the ancient, pre-computer days. And calling it an analog signal is a little specific for now, let’s just discuss analog itself. So the analog system is for storing information (or later, sending it). You’ve essentially got infinite possible values, and each individual value creates a list of values that represents something as a whole.
Think of it as a black and white picture, vs a colored picture. (Though this doesn’t make much sense for a few reasons. First, black and white came before colored, unlike digital and analog, and second, I’m pretty sure there are multiple shades of black and white). So, imagine a picture of black and white where there are no shades. Just either black or white. Then, imagine a colored photograph. You’ve got every shade possible, and any combination. (Technically, there’s a limited amount of colors your computer can show, but whatever. Imagination! This might be hard for us hard logic thinking computer programmers, but give it a shot). You’ve got the analog picture, the high-definition picture, with infinite values. You’ve got the black and white (#000, #fff, no shades!) that can represent a picture equally well, but does seem to miss some of the touch the other picture has. However, here’s where the interesting stuff comes in… If I send the image through a really bad email program that fails to send the high definition image, instead just adding random dots of color all over, you’ve got a massive blend of colors. It might be hard to tell what the image represents. Now if the black and white image were sent, had random colors added to it, you could remove the new colors, and figure out exactly what the image was before, because you know not to change the black and white, only the other colors… Now that I’m reading over this it doesn’t seem like a good example, so I’ll stop explaining this metaphor, and let’s jump into the history. Analog was used in the pre-computer area, and is still used today. Imagine the first forms of technology that involved storing information to be accessed later.
Think of a gramophone/phonograph. (Do a quick google search, you know what it is, but not the name). You have the needle over the disc, that reads the bumps and ridges, and plays sounds based off of it. When all combined, you have essentially an audio recording. Now, the ridges and slopes of the disc have infinite possible heights that specify the sound. This is the analog system. Now, let’s discuss the basics of the binary system, which we'll dive deeper into later.
Binary originated when computers first started. An efficient, base 2, that’s super easy to read fast, and store. Base 2 meaning it’s a number system that uses 2 digits. (0, 1). Generally we use the decimal system, aka base 10. You might also have seen base 16 (Hexadecimal), with 10 numerical digits, and the letters a-f. Anyways, getting off track, binary works in a system of switches, which is easy with 0s and 1s. Switching a 0 gets a 1, and switching a 1 gets a 0. You’ll see these all the time in computers. If you’re a bit more than a beginner programmer, you’ve probably used 0s and 1s as true or false in conditional statements before. Anyways, it is also based off of powers of 2. Another thing you see everywhere in computers. 2, GB, 4 GB, 8 GB, 16 GB, 32 GB, 64 GB, 128 GB, 256 GB, 512 GB, 1024 GB, 2048 GB, and the higher ones that I’ve never seen an RAM of, 4096 GB, 8192 GB, and so on… (I only know these because of all the time I’ve spent playing 2048). Now to demonstrate how the switches work:
A Slightly More In-Depth Look at Binary
0 1 0 1 0 1 1
Now the rightmost slot simply has a value of one. If there’s a 1 in it (think “true”, or “on”), that means that the total number has at least a value of one. It’s based on exponents of two, that I think can be better explained with a diagram. Heading to google drawings, give me a sec.
Ok, here’s the model I’ve made. Make sure to ignore the actual 0s and 1s in the binary, they're just there as placeholders for now.
Essentially, the value of a slot depends on its position. The index of the slot, to use list terminology, is the power the constant (2) is raised to. You’ll have to reverse the list before looking at the indexes, especially if you’re creating a calculator to convert binary in digits. That’s what I had to do on my binary simulation, which reminds me… Nvmd, I’ll link it after the next model. So now we know the values of each individual slot, but how do we calculate the actual value of the binary string.
So, what happens here is that if a switch is turned on, or evaluates to true, meaning there is a 1 in the slot instead of a zero, we add the value of the slot to the entire number. Any slots that have a 0, which are greyed out in the model above, are not included in the calculation.
The amazing thing I find about this system is the way you can achieve any real, positive number! You might find that difficult to believe, in which case I’ll demonstrate with a smaller situation.
0 0 = 0
This evaluates to 0. To go to the next number, you’d flip the last switch, which has a value of one.
0 1 = 1
Ok that worked, now we have to move up one number. Sooo, flip the other switch right?
1 1 = 3
Oh wait! The next switch doesn’t add one to the total value, it adds 2. So how do we get the string to evaluate to two! Well you have the switch with the value of one flipped out, and you need to go down one number, sooooo…
1 0 = 2
There it is. And if you didn’t understand how to achieve each number before, your mind might have just exploded (or before if you caught on), and really begun to understand the brilliance of the binary system.
If you want to experiment with flipping switches on your own, or want to see a sped up animation of going through a bunch of numbers with binary, visit my binary simulation that’s posted over here: (Binary Simulation + Animations)[https://replit.com/talk/share/Binary-Simulation-Animations/145295]
But hold on, you might be a major fan of binary now, but we still need to discuss why we don’t use the analog system. Wouldn’t it be easier to just write, 1, 2, 3, 147, or 2,837,438,743,738 simply like it is?
There are many reasons why analog is useful. It’s easier to process at a higher level. If your own server sent a message, you’d probably want it in analog instead of binary. Due to the reason that you can represent the values in a more condensed way, it also takes less space, (ie. bandwidth). In theory, an Analog signal can be more accurate, and instead of translating something and trying to simplify it, it keeps the original quality.
However, in reality, there is interference, and this means that the longer it is stored or travels, the less clear the data is. When altering the data, to either change the value or to try and fix interference, it is difficult to edit, change, or attempt to revert.
These cons are the pros of Binary.
One of the biggest advantages that really fueled the usage of binary signals over analog signals is the ability to repeat them. We’re going to discuss Binary and Analog in the context of waves.
So, here’s the part where I’ll be heading over to google drawings to really make a bunch of models. Let’s show an analog wave.
Now here, let’s discuss a few aspects of a wave. You’ve got the amplitude, the distance of the wave from the middle line. So just draw an imaginary line across the middle of the wave (horizontally), and above it, you have the distance from the line is the amplitude. So you have infinite possible values of amplitude. When something reads that a signal is arriving, it needs to read the value. Depending on the accuracy of the reader, you might be accurate enough, or you might not be. By the way, when I’m referring to infinite values, I’m not talking about the amplitude reaching a height of infinity, but that the decimal points in-between have infinite amounts. 3.1, 3.132432, right?
Anyways, now here’s the disastrous part about an analog wave. In theory, by connecting it to a repeater, which would take the signal and send out a new signal, sort of resetting its power. The idea is essentially the same thing as a repeater in minecraft, if that makes it easier to understand. Anyways, the reason I said “in theory”, was because of interference. When the analog signal encounters another wave as it’s flying around, they won’t go around each other. Instead they’ll combine, altering the wave. Here’s what happens:
Now here you’ll notice that the waves that are combined alter the original wave. You’ll see that it holds more resemblance to the top wave (our original analog signal), because I’ve decided it is more powerful. The weaker wave will not have as big an effect on the new wave. Now when the repeater arrives, it will amplify the incorrect signal. However, repeaters do help, because it strengthens the signal. If it didn’t, then the original signal would get weaker, and everytime it encounters a wave it’ll get more and more altered. However, they did implement systems to try and remove interference, but it is impossible to know the original signal exactly. If there are some weird parts that don’t make sense, it is possible to make a new signal. The technology is advanced enough to remove anything so that it sounds normal, but it dulls the signal, meaning the accuracy of the sounds are lost. You might have altered some of the volume or tone. Let’s take a look at another diagram here.
You can see we just sort of dulled the signal, removed some of the suspicious waves and sort of smoothed it out. This is good at removing interference, but it isn’t perfect. It also smooths out and dulls some of the original sound. Compare it to the original wave.
They’re similar, but there’s definitely some trace of the interference. If you look at the peak of the original wave towards the third quarter, you’ll notice it has been dulled out in the new signal with the interference removed. It’s the same amplitude as the wave before it. So bam, that’s analog waves for you! We used to use telephones and televisions, but they have now been replaced with digital signals for the most part. However, still today, many radios, ex: short wave. Now that we’re done with that, let’s head over to our last section!
Heading back to the drawing board.
Man it’s impossible to make a good looking digital signal so I’m going to have to use some outside the box thinking hmmm…
So here’s what a digital signal looks like. Very different from the analog signal as you can see there’s no in between. Each part looks like it's either one or the other, and that’s exactly what it is. You might argue that the lines that go up and down before going straight for a little bit have infinite signals, but there is no lag. The line is not slanted, so it passes over it instantly. It can’t be any one value out of infinite possibilities, it’s rather infinite values all at once, so it doesn’t work like that. If you don’t understand what I’m saying, that’s fine, I’m not sure I do either. Now look at the wave, and draw the imaginary line in between, like we did for the analog signal. Above it you’ve got waves at a specific amplitude, and below it you have waves with the same amplitude. Now, the high parts represent the switches that are on, and the low parts represent the switches that are off. Now let’s translate the wave into binary.
Looking at the start of the wave, you can’t exactly see it, but you know there was an on switch there, because the line comes from the top and then goes to the bottom. So let’s begin with a
1 or on switch. The next one is below the middle line, so
0. And then above,
0, and the last part we can just barely see,
1. All together, that makes the part of the signal that’s visible to us
1 0 1 0 1 0 1 0 1. Now this wave might not have been a very good example, but I don’t want to go back and make a new one. This wave doesn’t have a digit repeated twice or more in a row, such as
1 0 0 1, but alternates each time. A wave like that would be easy to visualize though. Nevermind, I’ll draw one out for you.
Now you’ll notice that the middle third of the wave doesn’t go back up. After receiving a wave, a computer will calculate exactly how long the representation of one switch lasts. Let’s just call that one unit. You’ll see that the first part of the signal switches once every unit, but in the middle, it remains at the bottom for 3 units. That means that there are 3 switches that are turned off. Let’s figure out the new binary string from this wave.
1 0 1 0 0 0 1 0 1. Bam, so that’s how you would have have repeats. Now, remember what one of the major drawbacks of analog signals was? The interference. Now because there’s only two possible values, it’s hard for a wave to come in and alter it so much that it actually changes the readability of the wave. If a wave comes in with a value of .3, the computer will know it’s interference, because it’s only expecting a 0 or 1. So with digital signals, it’s actually possible to know exactly which part of the waves are the original signal, or interference. Let’s show the diagram.
Now for fun, I’ve made the new interfering wave the same as the wave that interfered with the analog signal. I’ve also made it very strong, so they have about equal representation in the new wave! This is a very unusual amount of interference that would rarely happen. Generally, you would see something like this:
Now pardon me, I just scribbled this out, because it would take too much time to make it perfect. Now what you’ll see with this is that you don’t even really need to remove the interference, if we wanted to find the binary string. It would take us a few seconds. If a device received this that wasn’t programmed to remove the interference, it might even be able to manage just fine. The binary string for the latest model is simply
0 1 0 1 0 1 0 1 0. Easy. Now looking at the previous one, it’s a little bit more difficult. You can kind of see it, but it would take you a second. However, let’s take a look at the parts of the wave. The digital signals come down to what’s above and what’s below.
As you can see from this wave, the parts above it are the on switches, and the parts below are the off switches. Now to address a question I’m assuming you might be thinking, is that the on switch towards the end, looks like it might very well be 2 on switches (though you and I know it’s only one, cause we’re smart). In reality (my models are not very accurate, they’re all estimations, not scientific), the wavelength of the switches will be longer, in order to prevent this sort of issue from arising. Anyways, with the line in the middle, it’s pretty easy to tell what the string is. If you tried to remove the interference, guess what comes out:
I just realized after I uploaded it, that my wave with interference doesn’t include the last part of the wave, but whatever. If the wave continued, it would end up being accurate. However, don’t get me wrong, the model is accurate in what it shows. So bam! When removing the interference, it’ll straighten out the up and down lines, flatten the straight stretches, and change everything to a uniform distance. Then the repeater will send out a new strong signal, and have it travel the other half of the world that’s still left of the signal’s path.
All right, thanks for reading this all. I really appreciate and hope you liked it! There’s still so much to learn, specifically in the area of binary and digital signals. If you’re interested in more try to do some research on:
- How UTF-8 characters are made in binary
- Pros and cons of binary/analog signals
- History of analog/digital signals
Also, there are some cool simulations out there for binary, analog, and all types of waves and data transfer. Really recommend trying to see if you can find one to experiment by yourself. Any questions, please leave some in the comments (I might be able to answer, or maybe not). Thanks for reading, and please note, I wrote this entire thing off the top of my head in one sitting. So please, if you see anything in my models that is completely inaccurate, please tell me! I’ll update it if I have the time, or just add your comment to the end of the post so that other people can see it. If I’m missing any key information, feel free to comment. I understand that my models and that sort of thing are not 100% accurate, so please, understand that I drew them in google drawings in a few minutes. Thank you, and hope you liked it!