Bits are the cornerstone of contemporary technology, and here’s a few notes on bits (even though we’re gradually building AGI right now, bits are important).
Unary (base-1)
Using one hand there are 32 possible value permutations available, or well, 31 as you minus the 0 (1) from the biggest possible value (32). Your fist is zero. Thumb is one. The index is two. Middle is three. The ring is four. Pinky is five. Now your thumb and index finger represent six.
Binary (base-2)
A bit is short for binary digit.
Binary needs two things. 0 or 1, x or y, black or white, on or off, true or false, yes or no, ducks or geese, marmite or butter, I can go all day OR night. Electricity can have two possible values for computation, it’s either there or it’s not.
We use base-2 for tiny switches of 1s and 0s to represent things, we represent 0 as off and 1 as on because it’s easier for the world to agree to this standard.
Base-10 (decimal {“dec” meaning 10})
We use base-10 because we have 10 fingers. Computers, however, simplify complex calculations by operating in binary.
Transistors and switches
We cannot see the billions of tiny switches that are being turned on and off in our mobile phone devices, but we can see the output of the information that is being processed.
You can imagine two light bulbs (easier to imagine hardware so to speak than the tiny transistors). If both are off this means 0, if one is on to the left and the other is off, 1, vice versa, 2, and if both are on, 3. Now what if we want 4? See, we need to add more bits. If I had 3 light bulbs, I could represent 8 different values. 0, 1, 2, 3, 4, 5, 6, 7.
- What number is that? One hundred and twenty-three. Right? We’re just assigning meaning (from our educational intuition) to mathematically abstract 123 as to define it as 1 hundred, 2 tens, and 3 ones. When really it’s three digits together… All words are just sounds we make to represent things after all, this is a similar concept for us to agree on what 123 means, and now what binary digits represent.
123, the 3 is the 1 column (1), the 2 is the 10 column (10), and the 1 is the 100 column (100). We can do 100 = 1 + 10 x 2 + 1 x 3 or if we multply that out 100 + 20 + 3, now we see 123.
The base exponents are 100, 10, and 1. 10^0, 10^1 and 10^2. Change the base to binary now it’s fundamentally the same but 2^0, 2^1, 2^2, etc. Let’s say we have 4 2 1.
0 0 0 = 0, 0 0 1 = 1, 0 1 0 = 2, 0 1 1 = 3, 1 0 0 = 4, 1 0 1 = 5, 1 1 0 = 6, 1 1 1 = 7.
Why is 5 101, not 110 like 6 is? Remember positional weights.
Positional Weight
From Right to Left: ( 1 \times 2^0 ), ( 0 \times 2^1 ), ( 1 \times 2^2 ) Analogy: Think of it as floors in a building; the higher you go, the greater the value.
General Rule
In binary, a continuous sequence of ‘1’s signifies the maximum value for any given bit size.
- The maximum number for any bit size will have all bits as ‘1’.
- For a sequence of n bits, the maximum value is ( 2^n - 1 ).
Example
4-bits: Max number is ( 2^4 - 1 = 15 ), which is ‘1111’ in binary.
If we add an additional light bulb, so it’s 4 (so we can count higher), what would the patterns of 0 and 1s be for the number 8?
We need more hardware (bits) to increase the number of values we can represent to do more complex things.
1 0 0 0 = 8
We say byte which is 8 bits, which is a more useful unit of measure and it happens to be a power of 2, which makes it more mathematically convenient to work with. Eight zeros are 0, eight 1s are 255 (or 256 if you count 0). Maybe you see the pattern now?
Computers are really dumb. They need instructions, you can set binary digits to represent instructions to do things. We do this in various ways with physics (electromagnetism, yeah science bitch), wrapped up and modelled, distorted and abstracted, to do things.
65 is the number for the bit pattern 01000001 to represent the letter A in ASCII. Underneath the hood of your messages on your phone or email, it’s just a bunch of 1s and 0s being sent.
01001000 01001001 00100001 = HI! 72 73 33. Remember to read the bits from right to left, so 128, 64, 32, 16, 8, 4, 2, 1. 8 bits is a 1 byte, remember that and you’ll be ok.
Instead of using ASCII, the world now uses Unicode. Unicode is a standard that can represent every language in the world and emojis.
Representation
We all need to agree ultimately on what the 1s and 0s mean to communicate effectively. All we do is reduce things to representations, all we have are 1s and 0s to represent things. Just like how through evolutionary iteration and time we have developed language to represent things, we have developed a model of 0s and 1s to represent things. Google, Microsoft, etc. have all agreed on how to standardize our models. Like how we use a language or how we use a numerical system, metric or imperial, we have agreed on how to represent things.
Base-16 (hexadecimal)
Hexadecimal is base-16, it uses 16 digits. 0-9 and A-F. A is 10, B is 11, C is 12, D is 13, E is 14, F is 15. Hexadecimal is used to represent binary numbers in a more human-readable format. It is easier to read 0x1F than 00011111.
Bits Representation Example of RGB Colour (Red, Green, Blue)
1s and 0s. It’s all 1s and 0s baby. No electricity and electricity. On and off.
One of the most common ways to represent colour is RGB (red, green, blue). Each colour is represented by a byte (8 bits). So 8 bits for red, 8 bits for green, 8 bits for blue.
That would be 128 64 32 16 8 4 2 1. Meaning in each value there’s a maximum of 255 (256 - 1 as we don’t count the 0, so it’s really 0 to 255). With 3 bytes, we can represent 255 different values for each colour, which is 16 million different colours. 255 x 255 x 255 = 16,581,375.
It turns out that with RGB if we keep track of how much red, green and blue we have, we can represent any colour. Nuts, right? From white to black and everything in between. We do this we just three different colours. Every one of the dots (pixels) on your screen is represented by 3 bytes of data. Every single little pixel has this, these three numbers (red, green, blue) together say what colour it is.
If we have 72 red, 73 green and 33 blue, we get a nice yellow colour. 24 bits or 3 bytes are in each square pixel box, using different levels of values between 0 and 255 for each red, green and blue.
If you’ve got a photograph that’s 5MB, that’s 5 million bytes or 40 million bits. That’s a lot of 1s and 0s. Images get bigger and bigger because we throw more bits into them. We can do this because we have more storage and faster internet, or some of us do, the UK’s internet is a joke.
It depends on the context you construct the bits to represent (which can be anything if you program them to what you want them to mean), it’s all just 1s and 0s underneath, configurated by your computer to represent things. Software engineering is this model of 1s and 0s, and instructions to do things. I’m repeating this so often to drill into you that this is the magic of everything.
Context matters
In an email, they could represent text. Meanwhile, in a graphics program, they could symbolize colours. No matter how fancy our technology and hardware it boils down to 1s and 0s and instructions. The world is yours, hack it. You can build music notes and a program to write music, from frequencies, level changes, scripts and codes to alter any setting you want. With three numbers, similar to how we can represent any colour with RGB, we can represent any sound with three numbers, because sound is just a wave, with height, frequency and amplitude. 3 bytes, 24 bits, 1s and 0s, can represent any sound (or at least a good approximation of it, that’s useful to the human ear).
Video is a bunch of images, and images are a bunch of pixels, and pixels are just a bunch of 1s and 0s. Unlike the old cameras that used film, digital cameras use a sensor that captures light and turns it into 1s and 0s. Film is a chemical process, digital is a mathematical process.
“Motion picture” is a series of still images, and we can represent each image with 1s and 0s. We can represent each image with 3 bytes, 24 bits, 1s and 0s, just like we can represent any sound with 3 bytes, 24 bits, 1s and 0s. “Frames per second” is how many images we can show in a second. 24 frames per second is the standard for movies, 30 frames per second is the standard for TV, and 60 frames per second is the standard for video games. Our brains just interpolate that as being “actual motion”.
If you were to open up a Linux, Windows or Apple calculator app, the same pattern of 0s and 1s might be interpreted as numbers for addition, subtraction, multiplication, or whatever.