6.0k views
3 votes
4-One possible performance multiplication enhancement is to do a shift and add instead of an actual multiplication. Since 9 * 6, for example, can be written (2 * 2 * 2 + 1) * 6, we can calculate 9 *6 by shifting 6 to the left 3 times and then adding 6 to that result. Show the best way to calculate 13 * 7 using shifts and adds/subtracts. Assume both inputs are 8-bit unsigned integers.

User Yemu
by
4.0k points

1 Answer

1 vote

Answer:

Check the explanation

Step-by-step explanation:

The above question can be sovled in the below step by step way:

15 can be written as 16-1 = 24 -1

Therefore, 15 *13 = (24 -1)*13

= 13*24 - 13

Now, when we left shift a number we multiply it by 2k .Where k is no of times we left shifted it.

Therefore, 13*24 = shift 13 to left 4 times

15 * 13 = shift 13 to left 4 times and subtract 13 from it.

User Ian Hickson
by
5.0k points