2.75 Unsigned High Prod
★★★
Problem:
Suppose we want to compute the complete 2w-bit representation of $x\cdot y$, where both $x$ and $y$ are unsigned, on a machine for which data type unsigned
is w bits. The low-order w bits of the product can be computed with the expression x*y
, so we only require a procedure with prototype:
that computes the high-order w bits of $x\cdot y$ for unsigned variables.
We have access to a library function with prototype:
that computes the high-order w bits of $x\cdot y$ for the case where $x$ and $y$ are in two's-complement form. Write code calling this procedure to implement the function for unsigned arguments. Justify the correctness of your solution.
Hint: Look at the relationship between the signed product$x\cdot y$ and the unsigned product$x'\cdot y'$.
Code:
Last updated