Forum Discussion
Altera_Forum
Honored Contributor
14 years agoMultiplication Rounding
Hey guys, I am multiplying two 32 bit numbers using LPM_MULT. Each number is in Q16.16 fixed point format. The product is a 64 bit Q32.32 number. I then shift the product to the ri...
Altera_Forum
Honored Contributor
14 years agoJust some clarification,
Lets say you have Q2.2 notation. You have two numbers: 01.11=1.75 x 10.00=2.00 The product should be 3.50 If I do the binary multiplication in my calculator I get a Q4.4 result: 00111000 Now I perform the rounding by adding P(3) to P(7:4) I get: 0011+0001=0100 If I'm interpreting this correctly, it appears that my 3.5 rounded to a 4. But, there isn't any fractional part of the number. The rounding forced the result to Q4.0. Instead of getting 11.10=3.5, I got 0100=4. Now if I didn't do any rounding at all and just performed a shift to the right to align the decimal point, I would get: 00001110 = 000011.10 = 3.5 Maybe I'm confusing the concept of rounding. I want to get a rounded value, but I still want to have a fractional value. If I perform this rounding without the shift, then the output 0100 will go throughout the rest of the system and get interpreted as 01.00=1, since the decimal point is aligned throughout the rest of the system.