Numbering Systems

positional notation

definition - describes the numbering systems that we are used to dealing with (digits are valued by their distance before or after the radix point, ".".

example - 3.141 - the radix point assigns the values of the 3, 1, 4, and 1 digits

common number bases - decimal (base 10), hexadecimal (base 16), binary (base 2), octal (base 8)

Symbols Used by the Bases

Decimal Hexadecimal Binary Octal
0 0 0 0
1 1 1 1
2 2 10 2
3 3 11 3
4 4 100 4
5 5 101 5
6 6 110 6
7 7 111 7
8 8 1000 10
9 9 1001 11
10 A 1010 12
11 B 1011 13
12 C 1100 14
13 D 1101 15
14 E 1110 16
15 F 1111 17

Conversion Between Bases

Given a number with N digits of base B we can convert it:

...Any Base to Decimal
  1. Start with a digit
  2. Find the decimal equivalent of that -one- digit (refer to table). Let's call this number A.
  3. Count the number of places right/left of the radix point.
    (negative numbers for digits RIGHT of the radix and positive numbers) Let's call this number N.
  4. Multiply the decimal A with the base B raised to the N power.
  5. Repeat with every other digit
  6. Sum the numbers. This is your decimal number.

example...

CAB.1 to decimal

Expansion:
C*162 + A*161 + B*160 + 1*16-1
...
12*162 + 10*161 + 11*160 + 1*16-1
...
12*256 + 10*16 + 11*1 + 1 * 1/16
...
3072 + 160 + 11 + 0.0625
...
3243.0625

...Decimal to Any Base

To convert a decimal number D to base B, repeatedly divide B into D, with the remainder being another new digit

example...

9908 (in decimal) to to hexadecimal

Iterated modulos:
9908 / 16 = 619 R 4
619 / 16 = 38 R 11
38 / 16 = 2 R 6
2 / 16 = 0 R 2
...
4 11 6 2
4 B 6 2

...Between Hexadecimal, Binary, and Octal

Hexadecimal, octal, and binary numbers are related in such a way that makes it easy to convert between them (ie. They're all a power of 2). The quickest way to convert between these is to group digits and match equivalent symbols from the table above. These samples may help:

examples...

1101010011110101 (in binary) to hexadecimal
(Reasoning: binary is base 2, hex. is base 16; 16 = 24 power. So we group by four)
1101 - 0100 - 1111 - 0101
...(from referring to the table)
D - 4 - F - 5
D 4 F 5

7024 (in octal) to binary
(Reasoning: here, we are going to a smaller base (8 to 2); so we have to stretch the number, 8 = 23 power, so we expand to three)
7024
...(from the table, again)
111 - 000 - 010 - 0100
1110000100100

123ABC (in hex) to octal
(Reasoning: this might be confusing, so just take my word for it, you stretch to 2 places; there are two eights in a sixteen)
1 - 2 - 3 - A - B - C
...(from the table, again)
01 02 03 12 13 14
010203121314

Return to CSC2252

Copyright © 1999, Bruce Lin