Cheers,

Shawn

Thank you for the elaborated example.

Regarding BPF using IIR, are there any exceptions when compared to the procedure you described ?

Thank you

Gil

Using decimal numbers, 0x400 is 1024, and 1024 times 2^15 is, 1024 * 32768 = 33554432. If you convert this back to hexadecimal, then you get 0x2000000.

Using shifts, 0x400 << 12 is 0x400 with another 3 zeros on the right (12/4 is 3), or 0x400000. This has to be shifted left another three places (15-12 is 3). One shift results in 0x800000, two shifts 0x1000000 and finally the third shift is 0x2000000.

How are you doing the calculations?

Cheers,

Shawn

0x400 << 15 = 80000000 not 0x02000000. How did you get the anwer then?

]]>I want to know how to perform MAC calculations using Q-format numbers. ]]>

Thanks,

Shawn

I’m working on FIR implementation using Distributed Arithmetic. And I have to use Q format numbers for MAC calculations. I understood the concept of Q format number but getting confused about using them in calculations. Can you please help me?

Thanks. ]]>

I’m glad the article is useful for you. When the dividend is greater than the divisor, you need to know how much bigger it will be, or use a lot more bits in your result. For example, if you know that the magnitude of the dividend is no larger than one, and the magnitude of the divisor can be as small as 0.5, then the largest magnitude of the result would be 2. You could shift your result such that a value this large could be represented. If you had no restrictions, then you might need to keep a lot of bits in the result to represent the entire range of possible results. In my last example, the division of two Q15 numbers would require a Q30 number to hold the range of results possible.

The multiplication by reciprocal that I mentioned was to do with constant values. I think most C/C++ compilers these days would automatically change a division by constant to a multiplication automatically when optimization is done. I was probably thinking back to when I used to write things in assembly code. I wouldn’t recommend doing a reciprocal normally, unless the result is going to be multiplied by more than one different value afterwards.

I hope that helps.

Shawn