# Dealing with Q15 for arc Tan function

1. ## Dealing with Q15 for arc Tan function

Hi

I am using dspic libq library to experiment with Q15 functions. The difficulty I am facing is that _Q15sinPI() and _Q15cosPI return in range -32768 to +32767 corresponding to -pi to +pi. But _Q15atanYByXByPI() deals only on -45 to +45 degrees and returns-8192 to +8192. This gives me only solutions to first and 4th quadrant. How do derive the arc tan for 2nd and 3rd quadrant?

•

2. ## Re: Dealing with Q15 for arc Tan function

The restriction is necessary due to Q15 number range. You get +/- 45..90 degree range by flipping x and y. Other two quadrants by manipulating x and y sign.

•

3. ## Re: Dealing with Q15 for arc Tan function

Hi

_Q15 y = Q15(0.866);
_Q15 x = Q15(0.5);

_Q15 check = _Q15atanYByXByPI(x,y);

returns 8192 ( 45 degrees) and not 60 degrees. Even if I flip , results are same

•

4. ## Re: Dealing with Q15 for arc Tan function

returns 8192 ( 45 degrees) and not 60 degrees.
Can't return higher number by design.

Even if I flip , results are same
Don't know why, may be the library is faulty.

5. ## Re: Dealing with Q15 for arc Tan function

Can you share the link or lib file that works

--[[ ]]--