Electronic – How to multiply fixed point numbers of different format

binaryvhdl

Assume I have two 16 bit fixed point numbers in following format being multiplied.

Q3.13 * Q10.6

What is the correct way to multiply them, i.e do I right shift the first number to align it as Q10.6 or left shift the second number to align it as Q3.13? In both cases I will lose data.

May be the correct way is to put them into 32 bits and then shift them and then multiply them. In this case, no data is lost but result will be 64 bits after multiplication.

What Q format the result have after multiplying Q3.13 and Q10.6?

Best Answer

This isn't particularly different from multiplying two fixed point numbers with the same format. You need to do a multiplication which preserves the most significant bits, then shift the binary point back to the desired output format.

So, do a 16x16 => 32 bit multiplication. The binary point is then at position 13+6 = 19, so you have a Q13.19 format number.

Assuming you want Q10.6 format output, you shift right by 13, optionally check for overflow, then take the lower 16 bits.