Binary Multiplication Binary Multiplication Any multiplication can be
Binary Multiplication
Binary Multiplication Any multiplication can be re-expressed as a series of additions. For example, 7 * 3 (seven times three) is simply the sum of 3 sevens. 7*3=7+7+7 Since we already know how to perform addition, binary multiplication becomes easy.
Binary Multiplication 7 * 3
Binary Multiplication 7 * 3 0111
Binary Multiplication 7 * 3 0111 + 0111
Binary Multiplication 7 * 3 0111 + 0111 1110 + 0111
Binary Multiplication 7 * 3 0111 + 0111 1110 + 0111 10101
Binary Multiplication The multiplication of large values will take many such additions, but the machine doesn’t mind. Even so, we look for faster more efficient techniques, and there is one available. It’s based on the Algebraic property called Distribution.
Binary Multiplication The Distribution Property can be expressed this way: a * (x + y) = a * x + a * y Any number can be expressed as the sum of other numbers: 106 * 37 = 106 * (30 + 7) = (106 * 30) + (106 * 7)
Binary Multiplication The other insight necessary to optimize multiplication regards multiplying a number by its base. In Decimal, multiplying anything by 10 is easy q q simply shift the digits to the left, and pad with a zero. 975 * 10 = 9750
Binary Multiplication This is true in any number system. In Binary, for example: 001 represents 1 010 represents 2 100 represents 4
Binary Multiplication This is true in any number system. In Binary, for example: 001 represents 1 010 represents 2 100 represents 4 Each shift/pad doubles the value.
Binary Multiplication Now reconsider this problem: 106 * 37 = ?
Binary Multiplication Now reconsider this problem: 106 * 37 = ? Expressed as this distribution: 106 * (32 + 4 + 1)
Binary Multiplication Now reconsider this problem: 106 * 37 = ? Expressed as this distribution: 106 * (32 + 4 + 1) = 106 * 32 + 106 * 4 + 106 * 1
Binary Multiplication ? = 106 * 32 + 106 * 4 + 106 * 1
Binary Multiplication ? = 106 * 32 + 106 * 4 + 106 * 1 5 32 = (2 )
Binary Multiplication ? = 106 * 32 + 106 * 4 + 106 * 1 5 32 = (2 ) 2 4 = (2 )
Binary Multiplication ? = 106 * 32 + 106 * 4 + 106 * 1 5 32 = (2 ) 2 4 = (2 ) 0 1 = (2 )
Binary Multiplication ? = 106 * 32 + 106 * 4 + 106 * 1 5 32 = (2 ) 2 4 = (2 ) 0 1 = (2 ) by substitution… 5 2 ? = 106 * 2 + 106 * 2 0
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 0 This term can be simplifie d.
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 106 0
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 106 converts to 0 1101010
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 0 1101010 106 * 2 2
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 0 1101010 106 * 2 2 shift 2
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 2 shift 2 0 110101000
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 0 110101000 106 * 2 5
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 0 110101000 106 * 2 5 shift 5
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 5 shift 5 0 110101000000
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 5 106 * 2 0 110101000000 ==================
Binary Multiplication 5 2 ? = 106 * 2 + 106 * 2 5 106 * 2 0 110101000000 ================== Sum 111101010010
- Slides: 31