Recently in our software and portability class we learned about how data is handled in digital machines; digital in this context not meaning a digit or base ten number but a counting system that determines numbers with a binary (or base 2) representation of numbers. The topics that were discussed covered the basics from how bits can be interpreted as numeric values and how bits can be interpreted as character values for text; even including how images, audio and video are created and stored.
I personally found that a lot of the information presented in this part of the course to be completely new to me. During my time as a hobbyist I’ve spent considerable time trying to understand executable binaries, which you can see by checking my other recent post during our compiled C lab earlier in the course:
But now it’s time to branch off and dig into other kinds of data a little bit more:
Computers manipulate and store information in the form of 1’s and 0’s which can be represented by using either voltages on a wire or by the orientation of magnetic material such as on a hard disk or magnetic tape. There are also optical mediums that use the presence of; or lack of detectable light such as in Compact disk format. The main point I’m trying to make however is not so much about the medium used to represent the data but how the bits are set and interpreted.
Let’s start with integer values, or numbers without a decimal point (whole numbers). These values are handled in a way that is very similar to the usual base 10 counting system that many of us are used to. The only real difference between counting with base 10 and the way computers represent integer values is that binary is base 2 instead of 10. Basically this means that once values are exhausted in a single column, then a value in the adjacent left column is incremented by one and the value in the original column starts over again. The same is true when using a base 2 counting system like binary, except we only have two states for each valued column instead of 10, when that column increments past 1 we increment the adjacent left bit by one.
Binary column values for 4 bit values (0 -256):
| 0 | 0 | 0 | 0 | = 0
| 0 | 0 | 0 | 1 | = 1
| 0 | 0 | 1 | 0 | = 2
Similarly in Decimal:
| 0 | 0 | 0 | 0 | = 0
| 0 | 0 | 0 | 9 | = 9
| 0 | 0 | 1 | 0 | = 10
Although more columns are required to represent smaller numeric values, the concept is very similar during counting. Another way to make it easier to is to think of each column as having a value that is twice that of the column to the right of itself.
| 0 | 0 | 0 | 0 |
| 8 | 4 | 2 | 1 |
Using a simple addition you can determine the value of random binary values:
| 1 | 0 | 0 | 1 | = 9
| 8 | 4 | 2 | 1 |
8 + 1 = 9;
Interestingly numbers that have decimal points can be considerably more complex. There are multiple parts to consider when working with floating point numbers, such as the block of numbers before the decimal known as an exponent and the block of values after known as a mantissa or significand. This means of representing values is defined in IEE 754, and in our class time we learned that not only are there requirements in regards to how bits are set but also manipulated with shifts set by this standard.
To not steer my readers wrong I will admit that I do not have a strong grasp on binary representations of floating point values. I will however leave you with a few resources for your own personal study if you choose to learn more:
Here is a link to a calculator for working with these values which can help give some better understanding to those who may be interested:
Fixed Point Representations:
One of the downsides to floating point representation of numbers that operations that act on them can be computationally intensive due to their complexity. A way to get around this is to represent decimal numbers with integer numbers, which can be computed using standard integer operations and then displayed in a way that would be interpreted as a decimal number.
Audio Data Representations:
We we’re also taught about how audio is stored in computer systems, which admittedly has had an effect on how I know hear digital music. From what I understand the sound wave is “sliced” and a representation of that audio signals state is stored during that time. The quality of the overall audio files being determined by the number of “slices” (also known as samples,) that are stored.
Here is a link that I referenced when trying to gain a better understanding of this concept:
In the above article, not only does it give a good detail on the idea of sample rate but also bit depth and how they related to bit rate and file size. Because most people in this era consume some kind of digital audio, having an understanding is a good idea. Not only for knowing the quality of the audio file that you want but in regards to understanding your own data transfer and storage limitations.
Video Data Representations:
For video to be stored in a digital format it also is “sliced” into frames at different intervals depending on the desired quality of the image. These “slices” again called samples can be quite large in terms of file size, which requires some new tactics to bring the file size back down to a more realistic level. One of the ways that this is accomplished is via. removing unused parts of images and recreating the missing pieces in a way that the human eye would not be able to determine during casual viewing. Another option to limit file size is by lowering the number of values in the color palatte, and choosing a single common color value again, that would not be noticeable by the human eye.
Overall when it comes to video compression there are many tactics that are used together to make digital video a possibility. The hardest part now is to try watching digital video and try not to being aware or actively looking for it instead of enjoying the video itself.
Digital information can be really simple, however to make things work with our current technological limitations, it can also get very complex very quickly. Luckily we are provided with libraries that can handle these complexities, allowing us as modern programmers to accomplish the tasks we are working on while delegate the tough stuff to the people who understand it.