Governor's Career & Technical Academy Arlington

CSC 215: Binary, Octal, and Hex

Bin Oct Hex


Overview

Some of you have heard me say on more than one occassion, it's all just bits. This semester we are going to dig deeply into that saying, and I'll start the discussion with this introduction to the binary, octal, and hexadecimal number systems. I'll discuss what they are, why we use them, and why we need to become very comfortable with them to program the Altair 8800.

Number Systems

The Altair manual has a very brief section titled Number Systems which on careful reading reveals that what is being discussed is more properly referred to as a numeral system, and that what is really at issue is the Altair 8800's use of a positional numeral system in base-2 (see radix Wikipedia entry for more on that).

I only want to draw your attention here to the fact that positional number systems are not the only numbers systems humans have used. Most of you are probably at least somewhat familiar with the Roman numeral system, which is not a positional number system.

Bits and Binary Numbers

The word bit is a portmanteau of binary digit. In information theory is it the smallest unit of information, since it holds one of only two possible values, usually represented by 0 and 1, on and off, or true and false.

A binary number is a number expressed in base-2, which means it can be represented physically by bits.

For both engineering and mathematical reasons, almost all the computers in common use today are binary digital computers, which means they store and electronically operate on bits.

Bits and Binary Numbers

In case you do not feel comfortable with binary arithmetic, here are a few resources to help you brush up:

Octal and Hexadecimal Numbers

While the Altair 8800 uses binary numbers, these numbers, while very practical for machines, are much less so for humans, animals which seem to process things that vary in their environments more effectively than things which are all the same. We humans do not do well with long strings of 1s and 0s, go computer scientists early on started using numerical bases that represented groups of bits, thus providing more variety in the representation of numbers.

Any base which is a power of 2, such as 23, or 8 (called octal), and 24, or 16 (called hexidecimal), can map easily to the binary number system, since one digit in these two systems maps directly to 3 or 4 binary digits respectively.

After three years working with the Altair 8800, I am still not sure why the documentation uses octal, but I think it is because it maps most conveniently with the instruction set of the machine. As you will soon see, the grouping of bits on the front panel of the computer is arranged in octal.

Since the Altair 8800 has an 8-bit processor and a 16-bit memory address space, however, we will often find it much more convenient to use hexadecimal numbers. Experience from the past few years showed that we will need to become very comfortable with both systems.

The good news is that you will leave this experience with a solid foundation in numberal systems used on computers. When life gives you lemons, make lemonade! ;-)