# Computer Number Systems

All digital computers – from supercomputers to your smartphone – ultimately can do one thing: detect whether an electrical signal is on or off.
That basic information, called a *bit* (**bi**nary digi**t**), has two values: a 1 (or *true*) when the signal is on, and a 0 (of *false*) when the signal is off. Larger values can be stored by a group of bits. For example, 3 bits together can take on 8 different values.

Computer scientists use the binary number system (that is, base 2) to represent the values of bits. Proficiency in the binary number system is essential to understanding how numbers and information is represented in a computer. Since binary numbers representing moderate values quickly become rather lengthy, bases eight (octal) and sixteen (hexadecimal) are frequently used as shorthand. In octal, groups of 3 bits form a single octal digit; in hexadecimal, group of 4 bits form a single hex digit.

In this category, we will focus on conversion between binary, octal, decimal, and hexadecimal numbers. There may be some arithmetic in these bases, and occasionally, a number with a fractional part. We will not cover how negative numbers or floating point numbers are represented in binary.

## Resources

Ryan's Tutorials covers this topic in beautifully. Rather than trying to duplicate that work, we'll point you to the different sections:

- 1. Number Systems - An introduction to what numbers systems are all about, with emphasis on decimal, binary, octal, and hexadecimal. ACSL will typically identify the base of a number using a subscript. For example, $123_8$ is an octal number, whereas $123_{16}$ is a hexadecimal number.

- 2. Binary Conversions - This section shows how to convert between binary, decimal, hexadecimal and octal numbers. In the
*Activities*section, you can practice converting numbers.

- 3. Binary Arithmetic - Describes how to perform various arithmetic operations (addition, subtraction, multiplication, and division) with binary numbers. ACSL problems will also cover basic arithmetic in other bases, such as adding and subtracting together 2 hexadecimal numbers. ACSL problems will not cover division in other bases.

- 4. Negative Numbers - ACSL problems will not cover how negative numbers are represented in binary.

- 5. Binary Fractions and Floating Point - The first part of this section is relevant to ACSL: fractions in other bases. ACSL will not cover floating point numbers in other basis. So, focus on the section Converting to a Binary Fraction, but keep in mind that ACSL problems may also cover octal and hexadicmal fractions.

The CoolConversion.com online calculator is another online app for practicing conversion from/to decimal, hexadecimal, octal and binary; this tool shows the steps that one goes through in the conversion.

## Format of ACSL Problems

The problems in this category will focus on converting between binary, octal, decimal, and hexadecimal, basic arithmetic of numbers in those bases, and, occasionally, fractions in those bases.

To be successful in this category, you must know the following fact cold:

- The decimal values of hex digits A, B, C, D, E, F
- The binary value of hex digits A, B, C, D, E, F
- Powers of 2, up to 4096
- Powers of 8, up to 4096
- Powers of 16, up to 65,536

## Sample Problems

Insert non-formatted text here

### Sample Problem 1

**Problem:** Solve for $x$ where $x_{16}=3676_8$.

**Solution:** One method of solution is to convert $3676_8$ into base 10, and then convert that number into base 16 to yield the value of $x$.

An easier solution, less prone to arithmetic mistakes, is to convert from octal (base 8) to hexadecimal (base 16) through the binary (base 2) representation of the number:

$$\begin{align} 3676_8 &= 011 ~ 110 ~ 111 ~ 110 & \text{convert each octal digit into base 2}\hfill\cr &= 0111 ~ 1011 ~ 1110 & \text{group by 4 bits, from right-to-left}\hfill\cr &= 7 ~ \text{B} ~ \text{E} & \text{convert each group of 4 bits into a hexit}\cr \end{align}$$

### Sample Problem 2

'**Problem:** Solve for $x$ in the following hexademical equation: $ x= \text{F5AD} - \text{69EB}$

**Solution:**

One could convert the hex numbers into base 10, perform the subtraction, and then convert the answer back to base 16. However, working directly in base 16 isn't too hard. As in conventional decimal arithmetic, one works from right-to-left, from the least significant digits to the most.

- The rightmost digit becomes 2, because D-B=2.
- The next column is A-E. We need to
*borrow*a one from the 5 column, and 1A-E=C - In the next column, 4-9=B, again, borrowing a 1 from the next column.
- Finally, the leftmost column, E-6=8

Combining these results of each column, we get a final answer of 8BC2.

### Sample Problem 3

**Problem:** How many numbers from 100 to 200 in base 10 consist of distinct
ascending digits and also have distinct ascending hex digits when
converted to base 16?

**Solution:** There are 13 numbers that have ascending digits in both bases from 100
to 200. They are (in base 10):
123, 124, 125, 126, 127, 137, 138, 139, 156, 157, 158, 159, 189

## Other Resources

There are many YouTube videos about computer number systems. Here are a handful that cover the topic nicely, without too many ads:

TBD

TBD

TBD