Binary

Numbers in Binary

You can think of numbers in binary in a lot of different ways. A basic way to comprehend binary is to understand that each digit in a binary number, represented by a 0 or a 1, is 2 to the power of the number of numbers to the right of that number. for example, we know that 16 will be the 5th digit because 25-1 is 16. You can think of binary like pouring water into cups. If you have a pitcher with a certain number of mls of water, and you’re trying to exactly fill up as many cups as you can, and you have a cup that can store 2x the number of mls that the last cup could store, starting at 1ml, then, assuming that you have more than 1ml of water, you will be able to fill at least one cup, the 1ml cup. When you fill a cup, you give it a value of “1” or “true”. If you cannot fill the cup exactly, you give it a “0” or “false” value. In this example, you will start filling the cups at the biggest cup, which can fit lets say 128mls of water. That means that there will be 8 cups; 128mls, 64mls, 32mls, 16mls, 8mls, 4mls, 2mls and 1ml. If your jug of water has 117mls of water, you can’t fill the 128mls cup because 128>117mls, so you would give the 128mls cup a “0” value, because its not full. When you get to the 64mls cup, you can fill it, so you fill it, giving it a “1” value and subtracting 64mls from your total of 117mls of water, leaving you with 53mls of water. You then move to the 32mls cup, and you can also fill that one, because 53>32mls. you give it a “1” value and remove 32mls from your jug of water, leaving you with 21mls of water. After that, you move to the next cup that can hold 16mls of water, which you have in your jug, because 21>16mls. You give it a “1” value as well, and take out 16mls from your total water, leaving you with 5mls. The next cup can hold 8mls, which you don’t have, so you skip over it and give it a “0” value. You can fill the 4mls cup, giving it a “1” value and leaving you with 1ml left, which means that you can’t fill the 2mls cup but you can fill the 1ml cup, so you give them a “0” value and a “1” value respectively. This means that 117 in binary will be 01110101. To convert from binary back to base 10, you simply tally up how much water you would have if you poured all of the cups back into the jug of water, which would be 64+32+16+4+1, or 117mls.

Characters in Binary

Using the ASCII charset, computers can turn regular binary numbers into characters. ASCII is a set of characters that each have a value that corresponds to a number 1-255. If I wanted to convert the word “Binary” into Binary, then I would take the ASCII corresponding numbers for “B” “I” “N” “A” “R” and “Y”, which would give me “66” “73” “78” “65” “82” “89”, which I can then convert into binary as mentioned before. This gives me “01000010” “01001001” “01001110” “01000001” “01010010” “01011001”, which means absolutely nothing to me, but a computer can read it and output “BINARY”. ASCII Contains all sorts of characters, but only contains a total of 255 because 29-1 is 255, which makes sense because it means that ASCII doesnt have to use more than 8 binary digits to store numbers. 8, which is coincidentally 23, is the number of binary placeholders in a “byte”, and 1, which is 20, is a “bit”. To learn more about the characters that ASCII uses, visit this ASCII table.

Images in Binary

Computers can also create images using binary. It takes in the number of white pixels and black pixels in an individual row, then assigns numbers to the number of consecutive squares of each color based on how many of the black or white pixels there will be. Computers always start by default on white pixels, so if the pattern in that row starts with a black pixel, it will just display a 0 to show that it starts with 0 white pixels, then it will show the number of black pixels after it, which will be separated with a comma. The computer will also completely disregard all of the remaining white pixels at the end of a row if there are no black pixels following it. The code 1,3,2,4,1,1 in a 16 pixel (pixel stands for picture element) array will display 0,1,1,1,0,0,1,1,1,1,0,1,0,0,0,0. If you move the first white pixel to the back of the row, it will instead be 0,3,2,4,1,1, which displays as 1,1,1,0,0,1,1,1,1,0,1,0,0,0,0,0 (white pixels are 0, black pixels are 1). If anyone’s ever giving you a hard time, or if you just want to freak out people around you, find a nearby QR code and just start reading it until they go away (this actually does work).

Sound in Binary

To process a sound and convert it to binary, a computer measures the wavelengths of the sounds that are coming through a microphone and converts it onto a graph with the y axis representing voltage changes in the microphone and the x axis representing time. The y axis is measured in binary, which is why 16 bitrate (MP3) can process up to 65,536 (216) different pitches. The higher the number is plotted on the y axis, the higher the pitch is going to be. The audio is more than just a singular pitch, however, so thats why the computer will plot on the time axis as well, which gives it the audio shape that most of us are familiar with.
The computer then can convert the graph back into a sound wave to replay audio clips for the user.

Leave a Reply

Your email address will not be published. Required fields are marked *