taylorialcom/ Fundamentals

How Computers Think

Storing Information

Digital Systems - Binary

Unsigned Integers

Binary Unsigned Integers

Signed Integers

BinaryDecimal
\( 1000 \)\( -8 \)
\( 1001 \)\( -7 \)
\( 1010 \)\( -6 \)
\( 1011 \)\( -5 \)
\( 1100 \)\( -4 \)
\( 1101 \)\( -3 \)
\( 1110 \)\( -2 \)
\( 1111 \)\( -1 \)
\( 0000 \)\( 0 \)
\( 0001 \)\( 1 \)
\( 0010 \)\( 2 \)
\( 0011 \)\( 3 \)
\( 0100 \)\( 4 \)
\( 0101 \)\( 5 \)
\( 0110 \)\( 6 \)
\( 0111 \)\( 7 \)

Letters/Symbols

Colors/Images

Binary Representation of Colors
Figure 1: Binary Representation of Colors

Floating Point Numbers

Sounds

Acting on Information

Truth Tables

Suppose we wish to add two numbers, \( a \) and \( b \), together. For simplicity, we'll limit the range of values for these number between \( 0 \) and \( 3 \). We can list every possible combination of input values and the corresponding result, \( c \) (left two columns of the table below). The right two columns contain the binary representation for adding two 2-bit numbers together.

\( a + b \)\( c \)<- Decimal ... Binary ->\( a_2 a_1 b_2 b_1 \)\( c_4 c_2 c_1 \)
\( 0 + 0 \)\( 0 \)\( 0000 \)\( 000 \)
\( 0 + 1 \)\( 1 \)\( 0001 \)\( 001 \)
\( 0 + 2 \)\( 2 \)\( 0010 \)\( 010 \)
\( 0 + 3 \)\( 3 \)\( 0011 \)\( 011 \)
\( 1 + 0 \)\( 1 \)\( 0100 \)\( 001 \)
\( 1 + 1 \)\( 2 \)\( 0101 \)\( 010 \)
\( 1 + 2 \)\( 3 \)\( 0110 \)\( 011 \)
\( 1 + 3 \)\( 4 \)\( 0111 \)\( 100 \)
\( 2 + 0 \)\( 2 \)\( 1000 \)\( 010 \)
\( 2 + 1 \)\( 3 \)\( 1001 \)\( 011 \)
\( 2 + 2 \)\( 4 \)\( 1010 \)\( 100 \)
\( 2 + 3 \)\( 5 \)\( 1011 \)\( 101 \)
\( 3 + 0 \)\( 3 \)\( 1100 \)\( 011 \)
\( 3 + 1 \)\( 4 \)\( 1101 \)\( 100 \)
\( 3 + 2 \)\( 5 \)\( 1110 \)\( 101 \)
\( 3 + 3 \)\( 6 \)\( 1111 \)\( 110 \)


Computer engineers have techniques for building integrated circuits that replicate this input-output behavior. The figure above shows such a circuit. It is composed of a collection of logic gates that each take two inputs and produce one output.

The circuit above uses three types of logic gates that each have their own input-output relationship.

AND Gate



XYZ
000
010
100
111

OR Gate



XYZ
000
011
101
111

XOR Gate



XYZ
000
011
101
110

We could create a similar table for multiplying two 2-bit numbers together. In this case the result could be as large as \( 9 \), so we need four bits to represent the output:

\( a \times b \)\( c \)<- Decimal ... Binary ->\( a_2 a_1 b_2 b_1 \)\( c_8 c_4 c_2 c_1 \)
\( 0 \times 0 \)\( 0 \)\( 0000 \)\( 0000 \)
\( 0 \times 1 \)\( 0 \)\( 0001 \)\( 0000 \)
\( 0 \times 2 \)\( 0 \)\( 0010 \)\( 0000 \)
\( 0 \times 3 \)\( 0 \)\( 0011 \)\( 0000 \)
\( 1 \times 0 \)\( 0 \)\( 0100 \)\( 0000 \)
\( 1 \times 1 \)\( 1 \)\( 0101 \)\( 0001 \)
\( 1 \times 2 \)\( 2 \)\( 0110 \)\( 0010 \)
\( 1 \times 3 \)\( 3 \)\( 0111 \)\( 0011 \)
\( 2 \times 0 \)\( 0 \)\( 1000 \)\( 0000 \)
\( 2 \times 1 \)\( 2 \)\( 1001 \)\( 0010 \)
\( 2 \times 2 \)\( 4 \)\( 1010 \)\( 0100 \)
\( 2 \times 3 \)\( 6 \)\( 1011 \)\( 0110 \)
\( 3 \times 0 \)\( 0 \)\( 1100 \)\( 0000 \)
\( 3 \times 1 \)\( 3 \)\( 1101 \)\( 0011 \)
\( 3 \times 2 \)\( 6 \)\( 1110 \)\( 0110 \)
\( 3 \times 3 \)\( 9 \)\( 1111 \)\( 1001 \)

Your computer's CPU (central processing unit) contains a number of these these pre-built circuits for doing integer math and math for numbers with a decimal point (floating point math), along with other circuits for manipulating binary inputs.

Ray tracing, video rendering, and artificial intelligence problems require massive amounts of computation. GPUs (graphical processing units) contain many copies of a limited set of circuit types than CPUs. Software that is written to exploit massively parrallel operations can run exteremely fast compared to traditional CPU processing.

The circuits in CPUs and GPUs serve as the foundation for the software we create.