如何仅使用位移位和加法来进行乘法和除法?如何仅使用位移位和加法来进行乘法和除法?
3 回答
DIEA
TA贡献1820条经验 获得超2个赞
21 * 5 = 10101_2 * 101_2 (Initial step) = 10101_2 * (1 * 2^2 + 0 * 2^1 + 1 * 2^0) = 10101_2 * 2^2 + 10101_2 * 2^0 = 10101_2 << 2 + 10101_2 << 0 (Decomposed) = 10101_2 * 4 + 10101_2 * 1 = 10101_2 * 5 = 21 * 5 (Same as initial expression)
(_2
青春有我
TA贡献1784条经验 获得超8个赞
x << k == x multiplied by 2 to the power of k
x >> k == x divided by 2 to the power of k
x * 14 == x * 16 - x * 2 == (x << 4) - (x << 1)
x * 12 == x * 8 + x * 4 == (x << 3) + (x << 2)
- 3 回答
- 0 关注
- 469 浏览
添加回答
举报
0/150
提交
取消