Arithmetic of Binary Integers

All values printed in dark blue are decimal values. 

Binary addition:

     1 1
  00001010  (10 = 2 + 8)
+ 00001011  (11 = 1 + 2 + 8)
 ---------
  00010101  (21 = 1 + 4 + 16)


Binary multiplication:

     00001010  (10)
   * 00001011  (11)
    ---------
     00001010
    00001010
+ 00001010
 ------------
     01101110  (110 = 2 + 4 + 8 + 32 + 64)


Negation (2's complement):

  00001010  (10)
     ||
     \/
  11110101
+ 00000001
 ---------
  11110110  (246 = 2 + 4 + 16 + 32 + 64 + 128)

Indeed 10 + 246 = 256, so 246 represents -10 in a single byte.

Subtraction (2's complement):

  00001011  (11)
- 00001010  (10)
 ---------
  00001011  (11)
+ 11110110  (-10)
 ---------
 100000001  (257 = 1 + 256)
  ........
  00000001  (1)


Multiplication (2's complement):

     11110110  (-10)
   * 00001011  (11)
    ---------
     11110110
    11110110
+ 11110110
 ------------
 111010010010  (2706 = 2 + 16 + 128 + 512 + 2048)
     ........
     10010010  (-110 :: 146 = 2 + 16 + 128 = 256 - 110)


Binary long division:

Let's divide 00001110 (14) by 00000100 (4).
For our convenience, let's ignore the leading zeroes:


   11
 -----+
 1110 | 100
 100
 ---
  110
  100
  ---
   10

So the division result is 11 (3) and the remainder is 10 (2).