How can you multiply two unsigned 23-bit numbers if you only have memory locations that are 16-bits?
I am not performing these operations using x86 instructions, so information related to x86 will be ignored.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I assume you mean you can only multiply two 16-bit numbers at a time.
First I’m going to say that
aandbare the numbers we want to multiply. They are between 17 and 32 bits in size (which covers your 23). However big they are they’re zero padded out to an unsigned 32-bit size.can be re-written as
where
alandahare the low and high 16-bit parts ofa. Shifting by 16 is the same as multiplying by 2^16. We can then expand this equation.So you end up with 4 multiplies (
al*bl,al*bh,ah*bl&ah*bh) and you shift the results and add them together. Bear in mind that each 16-bit multiply produces a 32-bit result, so the whole thing will go into 64 bits. In your case, because you knowa&baren’t bigger than 2^23 the whole thing will fit in 46 bits.The other thing is that the summation will need to be done in 16-bit chunks, with the carry bits looked after.
Hope that helps.