NUMBER CONVERSIONS
 
 
  1. Decimal to Any base
  2. Binary to Decimal
  3. Binary to Hexadecimal
  4. Hexadecimal to Binary
  5. Hexadecimal to Decimal
  6. Binary Arithmetic
  7. Complementation
  8. Binary Subtraction
 
To
From
Decimal
(base 10)
Binary
(base 2)
Hexadecimal
(base 16)
Decimal
(base 10)
X
Decimal > Binary
Decimal > Hex
Binary
(base 2)
Bin > Decimal
X
Binary > Hex
Hexadecimal
(base 16)
Hex > Decimal
Hex > Binary
X

Decimal to Any base
Use the division/remainder technique.
Number Divided by Result Remainder
19 



1




2




0




1
1910 100112
--
Number Divided by Result Remainder
453 
28 
1
16 
16 
16
28 

0


1
45310 1C516

Binary to Decimal

Multiply the 1s in a binary number by their positional values, then sum the products.
 
 

28
256
 
27
128
26
64
25
32
24
16
 
23
8
22
4
21
2
20
1
Sum
 0000 1011
 
 
1*8 
1*2 
1*1 
1110
 0111 1111
 0
 
1*64 
1*32 
1*16 
 
1*8 
1*4 
1*2 
1*1 
12710


Binary to Hexadecimal

Segment the binary number into groups of four digits each.

Refer to an equivalence table.
0=0000, 1=0001, 2=0010, 3=0011, 4=0100, 5=0101, 6=0110, 7=0111, 8=1000, 9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111

Assign each group of four binary digits its hexadecimal equivalent.
110001012 = 1100 0101 = C516
 
Hexadecimal to Binary

Reverse the "Binary to Hexadecimal" process.

Refer to an equivalence table.
0=0000, 1=0001, 2=0010, 3=0011, 4=0100, 5=0101, 6=0110, 7=0111, 8=1000, 9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111

Assign each hexadecimal digit its group of four binary digits.
3E716 = 0011 1110 0111 = 0011111001112
 
Hexadecimal to Decimal

Multiply the digits in a hexadecimal number by their positional values.
 

168
4294967296
167
268435456
166
16777216
165
1048576
164
65536
163
4096
162
256
161
16
160
1
Sum
 3E7
3*256 
768
E*16 
14*16 
224
7*1
99910
4D6B
 0
0
4*4096 
16384
D*256 
13*256 
3328
6*16 
96
B*1 
11*1
1981910

 

Binary Arithmetic
Patrick J. Kidd -




The individual bits of a binary number are numbered as shown below (computers always count form zero instead of one!)

Bit number:    7 6 5 4 3 2 1 0
Binary code:  1 0 0 1 1 0 1 1
Bit 0 is sometimes called the least significant bit (lsb).
Bit 7 is sometimes called the most significant bit (msb).
 
Complementation

The rules for converting a negative decimal number to binary can be stated as follows:

  1. Find the binary value of the equivalent positive decimal number.
  2. Change all the 0s to 1s and all the 1s to 0s.
  3. Add 1 to the result.
An alternative method of finding the two’s complement is:
  1. Starting from the right, leave all the digits alone up to and including the first ‘1’
  2. Change all the other digits from 0 to 1 or from 1 to 0.
Example:
True form: 0000 1001 +910
One's Complement:
Add  00000001
1111 0110
0000 0001
XOR
Add 1
Two's Complement: 1111 0111 -910


Binary Subtraction

The easiest way of performing binary subtraction is to first convert the number to be subtracted to a negative number, and then add it. To subtract 12 from 15, using 1 byte for each number:

00001111  -  00001100
True form 
One's Complement 

Two's Complement

0000 1100
1111 0011 
0000 0001
1111 0100
+1210
XOR
Add 1 
-1210
  0000 1111 
1111 0100
0000 0011
15 
+(-12)
3

For example, to add the binary equivalents of 3 and -3, add the two’s complement to 3.

00000011  -  00000011
True form 
One's Complement 

Two's Complement

0000 0011
1111 1100 
0000 0001
1111 1101
+310
XOR
Add 1 
-310
  0000 0011 
1111 1101
0000 0000

+(-3)
0

Note:  The ‘carry’ of 1 is ignored.