我正在嘗試一個32位二進制乘法器的C++實現。我知道這樣做是二進制乘法器的C++實現
1011 (this is 11 in decimal)
x 1110 (this is 14 in decimal)
======
0000 (this is 1011 x 0)
1011 (this is 1011 x 1, shifted one position to the left)
1011 (this is 1011 x 1, shifted two positions to the left)
1011 (this is 1011 x 1, shifted three positions to the left)
=========
10011010 (this is 154 in decimal).
只是其中一種方法是否有另一種方式做到這一點是不那麼繁瑣的代碼,我必須做在較長二進制數的操作?
http://en.wikipedia.org/wiki/Multiplication_ALU#Implementations – 2013-04-08 12:45:58
如果你需要乘以32位數,爲什麼不使用64位類型呢? – Mikhail 2013-04-08 12:45:59