CISC 1115
Introduction to Programming Using Java
Numeral Systems

Numeral Systems

Hash Marks

Roman Numeral System

Positional Numeral Systems

The Decimal System

The Hexadecimal System

The Binary System

The Octal System

A comparison of the Numerals of the Different Bases

Decimal Hex Octal Binary Light Switch
0 0 0 00000 off off off off off
1 1 1 00001 off off off off on
2 2 2 00010 off off off on off
3 3 3 00011 off off off on on
4 4 4 00100 off off on off off
5 5 5 00101 off off on off on
6 6 6 00110 off off on on off
7 7 7 00111 off off on on on
8 8 10 01000 off on off off off
9 9 11 01001 off on off off on
10 A 12 01010 off on off on off
11 B 13 01011 off on off on on
12 C 14 01100 off on on off off
13 D 15 01101 off on on off on
14 E 16 01110 off on on on off
15 F 17 01111 off on on on on
16 10 20 10000 on off off off off
17 11 21 10001 on off off off on
18 12 22 10010 on off off on off

Indicating the Base/Radix of a Number

We indicate the radix or base we are dealing with using a subscript (written in decimal): 112 = 310 118 = 910 1116 = 1710

Converting TO Decimal

Hexadecimal to Decimal

Each position reflects a power of 16

To convert:
1AC16 =  
               C *   1  =    12 *   1  =     12 
             + A *  16  =  + 10 *  16  =  + 160
             + 1 * 256  =  +  1 * 256  =  + 256
                                           ----
                                            428

Binary to Decimal

Each position reflects a power of 2

To convert:
1001012 =  
            1 *  1 =     1
            0 *  2 =     0
            1 *  4 =     4
            0 *  8 =     0
            0 * 16 =     0
            1 * 32 =    32
                       ---
                        37

Any Base to Decimal

Each position reflects a power of the base/radix (e.g. 2 for binary, 8 for octal, 10 for decimal, 16 for hexadecimal)

To convert:

Converting FROM Decimal

Decimal to Hexadecimal

To convert:

428 / 16           R  12 = C 
  26  / 16         R  10 = A
    1  / 16        R   1 = 1
      0
				 
1AC

Decimal to Binary

To convert:

37 / 2           R  1
  18 / 2         R  0
    9 / 2        R  1
      4 / 2      R  0
        2 / 2    R  0
          1 / 2  R  1
            0

100101

Decimal to Any Base

To convert:

Converting Between Arbitrary Bases

In general, one can always convert between any two bases b1 and b2 by:

Converting Between Hexadecimal and Binary

You will have frequently need to convert between hexadecimal and binary and there is fortunately a simple shortcut:

Hex to Binary

To convert:

1AC16 =  0001  1010  1100 = 0001101011002

Binary to Hex

To convert:

1101011002 = 1  A  C = 1AC16

Binary Arithmetic

Addition of Binary numbers is similar to that of decimal: