This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I have trouble with IQmath working.
_IQ iqTemp1, iqTemp2, iqTemp3, iqTemp4;
iqTemp1= _IQfrac(_IQ(2.3456));
iqTemp2= _IQfrac(_IQ(-2.3456));
iqTemp3= _IQfrac(_IQ(0.3456));
iqTemp4= _IQfrac(_IQ(-0.3456));
and I get the results are
iqTemp1= -0.3456; iqTemp2= 0.3456; iqTemp3= -0.3456; iqTemp4= 0.3456, the mark of the result is opposite. any ideas?
Hi Gautam,
Thanks for your suggestion. Yes, I had check the example, But I can not get the same result, the mark of the result is always opposite.
Regards,
Liu
the mark of the result is always opposite.
That's very strange, Liu. Did you try with _IQxfrac like _IQ24frac?
Regards,
Gautam
I test the _IQ15frac, the mark of result is opposite. but the _IQint function is correct .
Regards,
Liu
After researching a lot here's what I concluded:
This is not an error, there is a misunderstanding of how the functions work.
Here's an example:
-2.3456 when rounded down (truncated) to the integer portion is -3.0. The fraction is .6544. When you add -3.0 to .6544 you get -2.3456 .
This is because IQmath does not use floating point numbers, but uses fixed point numbers, and simple fixed point operations.
Check accordingly and revert.
Regards,
Gautam
(Note: The above extract has been taken from http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/p/176794/1045860.aspx)
I figured out the problem after adding the latest compiler. It helped to point to the issue.
1. I was using the wrong compiler include: "C:\ti\ccsv5\tools\compiler\c2000_6.1.7\include" while using compiler 6.2.10
2. I was using the wrong IQMath.Lib resource file. My include is C:ti/controlSUITE/libs/math/IQmath/v160/include, but I was using c:\tidcs\DMC\c28\v32x\lib\dmclib\cIQmath\lib\IQmath.lib instead of C:\ti\controlSUITE\libs\math\IQmath\v160\lib\IQmath.lib.
Note: When I switched to 6.4.1, my project no longer fits. I'm sticking with 6.2.10.