Forum Discussion
Altera_Forum
Honored Contributor
15 years agoYou need the 64bit result from the integer multiply of two fixed point values, then you can extract the required bits to get the fixed point product.
(int)(((long long)x * y) >> 16) should give the correct value. However that multiply is likely to be a function call. If you are on an fpga with DSP multipliers then the mulxss instruction can be used to generate the high 32 bits. Otherwise it might be faster to do the 32x32 multiply yourself as four 16x16 multiplies. You need to take extra care for negative values! You might also persuade yourself that adding the HL+LH+LL products can't actually overflow 32 bits (I'm not sure).