Octal and Hex

Binary math is just as simple as decimal math, so is Octal and Hexidecimal.

NameBaseDigits
Binary
Octal
Decimal
Hexidecimal
2
8
10
16
0 1
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9 A B C D E F


Converting between bases is easy. To convert from Decimal to anything else you must first convert it to binary. This is taught in the first section of notes and will not be discussed here.

So why use Hexidecimal or Octal numbers? Well the reason we use Binary first off is because that is what computers use, and I can communicate quite easilly with it if I know binary. Lets use a perfectly random, made up example.

Example:
         1101001101010100
                             Lets rewite that as
         1101 0011 0101 0100   
                             So it is easier to view.
                             Now lets decode it....

         Digits 
          1       Direct/Indirect addressing
          2- 4    Operation
          5- 8    First Value
          9-12    Second Value
         13-16    Destination

So this may mean....
Using direct accessing mode, add register 3 to 5 and store the value in register 4.
So looking at the number 1101001101010100 its really hard to tell what is ment, however if I write that same number in Hexidecimal, I get D354 which is a lot easier to read and tells me a few things,
D=indirect add
3=first value
5=second value
4=destination
It is very easy to read and to translate. Some computers are designed around an Octal base (3 digit binary number) or a hexidecimal base (4 digit binary number) so it is advantageous to know both octal and hexidecimal conversion.

DecimalBinaryOctalHexidecimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
01101
01110
01111
10000
10001
000
001
002
003
004
005
006
007
010
011
012
013
014
015
016
017
020
021
00
01
02
03
04
05
06
07
08
09
0A
0B
0C
0D
0E
0F
10
11


Doing conversions is extreamly simple.
To convert from Binary to Octal divide your binary number into groups of 3, starting from the right side of the number. So, for example, 1010110111101 => 1 010 110 111 101. Second, now take each group of 3 and insert its Octal representation. 1 010 110 111 101 => 12675. So our nunber is 12675 in octal.

To convert from Binary to Hexidecimal divide your binary number into groups of 4, starting from the right side of the number. So, for example, 1010110111101 => 1 0101 1011 1101. Second, now take each group of 4 and insert its Hex representation. 1 0101 1011 1101 => 15BD. So our nunber is 15BD in hex.

Numbers are typically writen as follows:
     Decimal: 56
     Binary : 0111000b
     Octal  : x70  or 38o
     Hex    : 0x38 or 38h
Ok, so now we can convert between Decimal, Binary, Octal and Hexidecimal. When converting decimal places, however, you start from the left and divide the binary number into groups of 3 or 4. So basiclly you start at the decimal point and move out.