Binary Number Operations

| Comments

Addition

 10 + 0  0
 20 + 1  1
 31 + 0  1
 41 + 1  0, carry 1
 5
 6 For e.g
 7
 8    1 1 1 1 1    (carried digits)
 9      0 1 1 0 1
10+     1 0 1 1 1
11    -------------
12=   1 0 0 1 0 0 = 36


Subtraction

Subtraction
 1
 20  0  0
 30  1  1, borrow 1
 41  0  1
 51  1  0
 6
 7Subtracting 1 digit from 0 digit produces the digit "1", while
 81 will have to be subtracted from the next column. This is known as
 9borrowing.
10
11      *   * * *   (starred columns are borrowed from)
12      1 1 0 1 1 1 0
13         1 0 1 1 1
14    ----------------
15=     1 0 1 0 1 1 1


Multiplication

Multiplication
 1
 2        1 0 1 1   (A)
 3      × 1 0 1 0   (B)
 4       ---------
 5        0 0 0 0    Corresponds to the rightmost 'zero' in B
 6+     1 0 1 1      Corresponds to the next 'one' in B
 7+   0 0 0 0
 8+ 1 0 1 1
 9  ---------------
10= 1 1 0 1 1 1 0
11
12Binary Multiplication for binary point
13                1 0 1 . 1 0 1       A (5.625 in decimal)
14                × 1 1 0 . 0 1       B (6.25  in decimal)
15           -------------------
16                  1 0 1 1 0 1     Corresponds to a 'one' in B
17    +           0 0 0 0 0 0       Corresponds to a 'zero' in B
18    +         0 0 0 0 0 0
19    +       1 0 1 1 0 1
20    +     1 0 1 1 0 1
21    ---------------------------
22    = 1 0 0 0 1 1 . 0 0 1 0 1  (35.15625 in decimal)


Negative Binary numbers

How can we represent a negative number? We cannot use a ‘-‘ sign because all we can store in the computer is zeros and ones.

There are three methods

  1. Signed Magnitude
  2. 1’s Complement
  3. 2’s complement

Full text about binary number operations.

Credits

CS Camosun

Comments