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.

IQmath wrong output

I have observed this strange behaviour.

I am using this call:

xsqrPysqrQ15 = _FtoIQ15(x*x+y*y);

where x & y are float and xsqrPysqrQ15 is _iq15 quantity.

if y = 233.1827

then for x < -105.6 I get the output of the above call as 0 (zero).

if x = -105.6 or -105.5 or -105.4 or -100 then result is correct.

Similarly for same value of y, if x > 105.6 I get result as 0.

Can someone please help what is it I am missing here - like are my inputs out of range for the function?

Processor used: c6455.

IQmath ver_213

Thanks

SBanik

 

  • SNBANIK said:
    are my inputs out of range for the function?

    That would be my first guess.

    The way I would debug this is to break out the x*x and y*y to intermediate variables, add them to an intermediate variable, and look at the values you get in a CCS watch window. The IQMath documentation includes the valid range for each QN selection, as I recall. It is fairly easy to figure for yourself, though, since the xsqrPysqrQ15 variable is a 32-bit variable with 1 sign bit and 15 fraction bits, leaving 16 integer bits - so the positive integer-portion range is up to 2**16 - 1.

     

    If this answers your question, please click  Verify Answer  on this post; if not, please reply back with more information to help us answer your question.