I'm working on writing a C program to perform division of 2 complex numbers in Fixed Point. I'm not able to get the fractional part from it. Below is more details on it.
I have 2 complex numbers:
N = a + ib
M = c + jd
I need to do N/M
in fixed point (not using floating point)
Example values for the above complex numbers can be:
a = 1.55, b = 1.44, c = 1.24, d = 0.55
N = 1.55 + i(1.44)
M = 1.24 + j(0.55)
For converting to Fixed Point, I multiply these a, b, c and d with 2^14
.
After that they become:
a = 0x6333, b = 0x5c28, c = 0x4f5c and d = 0x2333
Then to perform the N/M
operation I do:
N/M = (a + ib)/(c + jd) = ((a + ib) * (c - jd)) / ((c + jd) * (c - jd))
Then for the real part alone:
(ac + bd) / (c^2 + d^2)
and so on..
The issue I'm facing is that I'm not understanding how to get the fractional part from the division. I'm getting only the decimal part which is mostly either 1 or 0.
What is the correct way to get the fractional part? In the above example, the real part should be something like 1.47490. But I'm only able to get 1.
Can anyone please help me with the right way in doing the complex division for Fixed Point?
Thank you very much.
In fixed point division and multiplication one must notice that the result value must have also scaling factor K.