Encoding - BIN, OCT, DEC, HEX

Numbering systems

Types: Decimal, Oct, Hex, Binary
Syntax: Subscript is used to show the base.

Adding in other systems

Example: In Oct

Converting between systems

BIN to DEC

Multiply wherever it has 1 by 2bit pos then add everything. (bit pos start from 0)

Example

Binary 1 0 1 0 1 1 0 1 Result
Multiply by 128 64 32 16 8 4 2 1 -
Decimal 128 0 32 0 8 4 0 1 128+32+8+4+1=173

DEC to BIN

  1. Divide decimal number by 2
  2. Save remainder (It represents the binary number on the right (Least significant bit))
  3. If quotient is > 0, repeat step 1 but divide by quotient
  4. Binary result = the remainders of Step 2 from the last
Example

Division=Quotient (Remainder)102=5(0)52=2(1)22=1(0)12=0(1)

As shown, need to divide until Quotient == 0
1010=10102

Lookup table

Useful for converting between BIN HEX or BIN OCT

BIN OCT HEX DEC
0000 0 0 0
0001 1 1 1
0010 2 2 2
0011 3 3 3
0100 4 4 4
0101 5 5 5
0110 6 6 6
0111 7 7 7
1000 10 8 8
1001 11 9 9
1010 12 A 10
1011 13 B 11
1100 14 C 12
1101 15 D 13
1110 16 E 14
1111 17 F 15
Fun way of converting A16 to 10102. A16=1010. And in binary, there's 2 10s