Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.46 KB

File metadata and controls

53 lines (38 loc) · 1.46 KB

Unsigned binary arithmetic

Be able to:

  • add two unsigned binary integers
  • multiply two unsigned binary integers.

Addition

Adding two binary integers is similar to adding two positive decimal integers. Each bit is added in turn starting from the right most bit (least significant) and continuing to the most significant bit (MSB).

Rules for addition

  • When two bits are both 0, the sum is 0.
  • When one of the bits is 1 and the other is 0 then the sum is 1.
  • When both bits are 1 then you must carry a 1 into the next bit's sum and then place a 0 in the current bit

Example

1 0 0 0 1 1 0 1 + 0 1 1 0 1 0 0 0

	1 0 0 0 1 1 0 1
+	0 1 1 0 1 0 0 0
-----------------------
Sum:	1 1 1 0 0 1 0 1
Carry:        1
Total:  1 1 1 1 0 1 0 1

Multiplication

Binary multiplication is very simple. To multiply two binary integers you sum the values of shifting the first number by every 1 in the second number. It is similar to decimal multiplication.

Rules for multiplication

  • When multiplying by a 0 bit the value is all 0's
  • When multiplying by a 1 bit, the value is the original number shifted by the number of bit up to the 1 bit
  • Remember to sum all the numbers at the end

Example

1 0 0 0 1 1 0 1 X 0 0 0 0 1 0 0 1

           1 0 0 0 1 1 0 1
x          0 0 0 0 1 0 0 1
--------------------------
           1 0 0 0 1 1 0 1
   1 0 0 0 1 1 0 1 0 0 0 0	    
--------------------------
   1 0 0 1 0 1 0 1 1 1 0 1