find the product
you have an eight bit multiply operator that takes two 8 bit numbers and returns a 16 bit value. Given two 16 bit values stored in 32 bit int variables, find the product using the
8 bit multiply operator.
8 bit multiply operator.
int multiply8bit(int m, int n)
ReplyDelete{
int mLow_nLow = (m & 0x00FF) * (n & 0x00FF);
int mHigh_nLow = ((m & 0xFF00)>>8) * (n & 0x00FF);
int mLow_nHigh = (m & 0x00FF) * ((n & 0xFF00)>>8);
int mHigh_nHigh = ((m & 0xFF00)>>8) * ((n & 0xFF00)>>8);
return mLow_nLow + (mHigh_nLow<<8) + (mLow_nHigh<<8) + (mHigh_nHigh<<16);
}