 About me Home Resumé CV Pictures Course Work CSE300-FA98 Teaching Portfolio CSE240-SP99 CSE207-FA03 Misc eHarmony Documents Tools # Number Systems - Overview

Number systems and codes are used to give meaning to collections of symbols. A number system consists of an alphabet. Number systems fall into one of three primary types. These are counting, relative position, and absolute position.

## Counting Number System

The least useful number system, but certainly the simplest, is the counting system. This number system has an alphabet of only one character. This character is written once for every value to be added to the total number. The position of the characters has no meaning. Arithmetic is very simple to do in this number system, but representing moderately large numbers is difficult. This system is most commonly used by people taking surveys on a clipboard.

For example

3 = `III`
19 = `IIIII IIIII IIIII IIII`

## Relative Position Number Systems

Relative position number systems allow larger numbers to be represented fairly efficiently compared to counting number systems. In this type of number system, the value of a number is the sum of all the parts unless a character precedes a larger one, in which case it is subtracted. One popular relative position number system is the Roman Numeral system still used on many clocks. This system has an alphabet that consists of `I`=1, `V`=5, `X`=10, `L`=50, `C`=100, `D`=500, `M`=1000

For example

18 = `XVII`
19 = `XIX`

This number system has several drawbacks. Most notably, arithmetic is very difficult (what is `XII + VII`?). Also, large numbers are difficult to inturpret (what is `MCMXCVIII`?).

## Absolute Position Number Systems

Absolute position number systems are the most familar systems to us. They offer the greatest utility in terms of representing large numbers as well as performing complex mathematical operations on them. These number systems consist of a base which is equal to the number of characters in the alphabet. Base10, or decimal, is familar to everyone. The value of a number is equal to the sum of the parts scaled by their position. Positions start at 0, and work left increasing by one with every additional character.

For example

4093 = `4`*103 + `0`*102 + `9`*101 + `3`*100

Binary (Base2) Alphabet = `0, 1`.
Octal (Base8) Alphabet = `0, 1, 2, 3, 4, 5, 6, 7`.
Decimal (Base10) Alphabet = `0, 1, 2, 3, 4, 5, 6, 7, 8, 9`.
Hexadecimal (Base16) Alphabet = `0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F`.

For example

10010011Base2 = `1`*27 + `0`*26 + `0`*25 + `1`*24 + `0`*23 + `0`*22 + `1`*21 + `1`*20 = 147Base10
1ADBase16 = `1`*162 + `A`*161 + `D`*160 = 429Base10

The decimal point, or more generically the radix point, marks the position where the fractional portion of a number starts. The negative positions, and therefore negative powers of the base, result in fractional values to the right of the radix point.

For example

1001.0011Base2 = `1`*23 + `0`*22 + `0`*21 + `1`*20 + `0`*2-1 + `0`*2-2 + `1`*2-3 + `1`*2-4 = 9.0022Base10

In this course, we will be using binary and hexadecimal most of the time. Hexadecimal can be thought of as binary digits grouped together rather than as an independent number system. This should feel very similar to working with large decimal numbers where commas are used to group digits like 1,273,481,285. Working from right to left, group 4 binary digits together and replace with the single hexadecimal character. Similarly, writing out the binary value for each hexidecimal digit will convert from hex to binary.

For example

0x123 = 0001 0010 0011
10100111010 = 0101 0011 1010 = 0x53A

When selecting a number system, always remember that wise selections can make your life easier. Spend the time looking at your design options before rushing on the first idea that looks like it will work.