- What are w-bit words in computer architecture ?
- For two 7 bit words 开发者_StackOverflow中文版
1011001 = A 1101011 = B , how does multiplication returns
10010100110011 ?
Isn't there simple binary multiplication involved in these ? Please provide an example.
w-bit is just the typical nomenclature for n-bit because w is usually short for word size
Both adding and multiplying are done just the same as in decimal (base 10). You just need to remember this truth table:
Multiplying
-----------
0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1
Adding
-----------
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0 (w/ carry)
First adding. To add, you add just like you would in normal arithmetic, except follow the truth table above:
00000101 = 5
+ 00000011 = 3
--------------
00001000 = 8
How this works is that you start from the right and work left. 1 + 1 = 0
, but you carry a 1
over to the next column. So the next column is 0 + 1
, which would be 1
, but since you carried another 1
from the previous column, its really 1 + 1
, which is 0
. You carry a 1
over the next column, which is 1 + 0
, but really 1 + 1
because of the carry. So 0
again and finally move the 1
to the next column, which is 0 + 0
, but because of our carry, becomes 1 + 0
, which is 1
. So our answer is 1000
, which is 8
in decimal. 5 + 3 = 8
, so we know we are right.
Next, multiplying:
00000101 = 5
x 00000011 = 3
----------
101 = 5
+ 1010 = 10
----------
1111 = 15
How this works is you multiply the top number 00000101
by the right most digit in the second row. So 00000011
is our second row and 1
is the right most digit, so 00000101
times 1
= 101
. Next you put a 0
placeholder in the right most column below it, just like in normal multiplication. Then you multiply our top original number 00000101
by the next digit going left in our original problem 00000011
. Again it produce 101
. Next you simply add 101 + 1010 = 1111
...That is the answer
Yes, it's simple binary multiplication:
>>> 0b1011001
89
>>> chr(_)
'Y'
>>> 0b1101011
107
>>> chr(_)
'k'
>>> ord('Y') * ord('k')
9523
>>> bin(_)
'0b10010100110011'
If you want to multiply, you simply do the multiplication the same as with decimal numbers, except that you have to add the carries in binary:
1011001
x1101011
-------
1011001
1011001.
0000000..
1011001...
0000000....
1011001.....
1011001......
--------------
10010100110011
w-bit words aren't anything by themselves. Assuming that the value of w
has been previously defined in the context in which "w-bit word" is used, then it simply means a word that is composed of w
bits. For instance:
A version of RC6 is more accurately specified as RC6-w/r/b where the word size
is "w" bits, encryption consists of a nonnegative number of rounds "r," and
"b" denotes the length of the encryption key in bytes. Since the AES
submission is targetted at w=32, and r=20, we shall use RC6 as shorthand to
refers to such versions.
So in the context of that document, a "w-bit word" is just a 32-bit value.
As for your multiplication, I'm not sure what you are asking. Google confirms the result as correct:
1011001 * 1101011 = 10010100110011
精彩评论