this is cordic multiply function I got a code when I run across from internet. But It's quite a bit different from expected data. How to modify to have this code with correctness?
update code
for (i=1; i=<8; i++)
{
if (x > 0) {
x = x - pow(2,-i);
z = z + y*pow(2,-i);
}
else{
x = x + pow(2,-i);
z = z - y* pow(2,-i);
}
If I do run with x=7, y=8 then z=7.000 not 56.
What is the wrong point?
update2
I got the right answer but Thnaks, I have checked the range it works. Bytheway, is there any extension range algorithm? How to make range extension?
It looks like you took this function from this paper (without attribution!). The code is full of obvious typos, but if you read the paragraph below the function it says:
Take home message: always read the accompanying documentation for any code that you plan to use, especially if you don't understand how it works.