Computer Science #4: Revamp, Binary, Logarithms

I’ve replaced the first edition of CODE by Charles Petzold, which came out in 1999, with this newer edition which came out this past August in 2022.

There are a few improvements in the early chapters. Like in the old one it says telephone, in the new one it says cell phone. But the concepts are still the same, so there’s nothing worth me going back over it.

I read the first 10 chapters. All it went through was the structure of minimal languages, specifically Morse code, braille, and binary numbers. Then it takes you through Boolean algebra and logic gates. I don’t feel like going back over those. So if you’re that interested in them, just go read the first 3 computer science posts on my blog. I’m gonna pick up where I left off in chapter 11.

Morse code and binary numbers are both binary languages; bi-nary, meaning they’re ‘of 2’. All of Morse code is an arrangement of dots and dashes. All of binary number language is arranged of 0s and 1s. Braille isn’t exactly binary, it’s strictly made of dots. It can only go up to a 3×2 arrangement. So there are a lot more combinations in that compared to Morse and binary, but it’s still a fairly minimal language. Compare those 3 to the English alphabet where we got 26 letters.

Now all those little pieces of those languages, the dot and dash of Morse, the 0 and 1 of binary, or even each of the letters of the alphabet, are considered bits. A bit is the smallest unit of information possible. Just as a penny is the smallest unit of money.

In this old poem called Paul Revere’s Ride, he made a basic system of lighting 1 or 2 lanterns to alert the American colonies if the British were invading. The famous line, “One if by land, two if by sea”

Now the land and sea are the only conditions of this situation. If all they cared about was whether the British were coming or not, they’d only need one lantern, yes or no.

So in the realm of electronic communication, the more conditions you add, the more bits we have to use.

Look at phone numbers, starting with area codes. There are 10 numeral digits, 0-9. An area code has 3 digit places. So all possible area codes are between 000-999, a total of 103, 1000 area codes. Once you set an area code, there are 7 more digits to go. That’s a total of 10,000,000, or 107 possible numbers after that one area code.

The same goes for binary code. Starting off there’s only 1 bit that represents 2 values, 0 and 1. Every time you add a bit, those values double. So 2 bits would represent 4 values, 00, 01, 10, 11. 3 bits represents 8 values, 4 bits reps 16, 5 bits reps 32 and so on.

Now in terms of the total values, each bit would represent the power of that total. Again, 1 bit is 2 values, so that would be 21. 2 bits is 4 values, so that’d be 22 and so on.

So what if we already knew how many values we have, but don’t know how many bits there are? To solve this we’d use a base-two logarithm, remember binary code uses the base-two number system. Let’s say we have 128 values. We first click ‘log’ and parentheses will pop up. We input our total values, which is 128, then we divide that, click ‘log’ again and input ‘2’ so it knows we’re using the base-two system. Equal that, and our answer is 7, which means that 128 is the result of 27.

One thought on “Computer Science #4: Revamp, Binary, Logarithms

Leave a comment