The journey of a thousand miles begins with a single step.
You have to crawl before you can run.
In order to become an effective computer scientist, you have to learn the basics. It's disturbing how often this is glossed over these days, but it is the truth. This series will cover a host of
Computers are dumb.
Computers follow very rigid patterns of logic, which we call programs. Without understanding this logic, we cannot cause a computer to perform even the simplest tasks, leaving us without the foundation for the more complicated tasks.
What is logic
Logic is, fundamentally, a system of rules by which we can derive certain truth. It
For part 1, see CS 101 - Introduction to Logic
Solution to last week's problem
In our last post, we considered the following problem:
if( m == k * k || i == 1 && j == 1)
printf("What's the result?");
It turns out that boolean (read: computer binary) logic also operates on
You may have heard the old programmer's joke:
There are 10 kinds of people in this world:
Those who understand Binary,
And those who don't.
This is an excellent introduction into the topic.
Computers, being dumb machines, are composed primarily of a host of switches. These switches have two states: ON and OFF (or CLOSED and OPEN). When the
In my last post, we discovered binary as a form of numeric representation. Like decimal, we can perform basic arithmetic operations with binary (and, consequently, hex).
We all know that 1 + 1 = 2, right? In binary, 1 + 1 = 10, as 10 is the binary representation of 2. By the same token,
(Apologies for the relatively content-free submission, but my buffer ran dry. This is a bit of a rushed post.)
We have seen that a computer represents data as binary bits. These bits are commonly grouped into eight-bit units, which we call bytes.
One byte can store up to 256 possible values. These values (in this case,
We now have some understanding of what bits are and how we work with them, but how do we store them?
A register is a computer element which stores bytes of data. There are several ways to build these registers, but their core function is to hold onto data for future use.
Consider the following pseudocode:
Apologies for the title, but I can't think of a better way to put it.
The simplest way to handle integers in binary is to treat every number as a positive number. This is called the unsigned integer representation. With the exception of subtraction, studied earlier, we have always used the unsigned integer representation before.
This section should wrap us up on binary for now.
Floating Point Numbers
Up until this point, we have dealt exclusively with integer representation binary. Everything we have done has been a whole value, with no fractions.
Floating point numbers are those fractions. More accurately, it is a number whose values can be between one and zero.
As we have discussed previously, computers operate as a huge array of switches, which operate in the on and off positions. What, we can reasonably ask, defines whether the switch is off or on?
The answer: electricity.
Buses: Wires connecting switches
The average computer contains many hundreds of feet of wire, designed to carry electrical charges between