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.

sqrt function gives slightly different results - may be rounding problem

hello friends,

I am using C6713 floating point DSP with CCS3.0.

I am implementing a program on DSP that was previously implemented on PC in Microsoft Visual C++ 6.0. Everything works fine until we use the SQRT Function, which gives slightly wrong results. For comparison, i am pasting the value that i got problem with.....

PLZ reply soon as i have a very urgent deadline to meet....!!!!

 

On PC using MSVC 6.0 on Win XP: SQRT(272331606109.836770079975) = 521852.000

On DSP in CCS3.0: SQRT(272331606109.836770079975) = 521850.3

 

For the record,  I have also tried double data type on DSP, but still didn't get any useful result.

All I want to do is to get the exactly same result as I got on PC. Please do reply soon.

Adnan

 

  • Adnan,

    Please reconsider your accuracy requirements, especially relating them to the real requirements of your project.

    When I ran the sqrt function (is your SQRT() a special VC++ function that uses capital letters?) on an old version of VC++ 6.0 I got the following answers:

    float result = 521854. (no additional 0's below the decimal pt)
    double result = 521854.00842557

    The constant you have specified requires around 80 bits to accurately store just the mantissa, without considering space for an exponent.

    If you need greater accuracy, double is certainly the way to go. Please specify the results you got using double on the PC and DSP. Also, please explain why these results are not useful for your project.

  • may be  precision error ,

    normally you can use 64 bit  floating in PC and 32 bit  on dsp ,

    in 32 bit  ,  23 bit resolution for  detail. sometimes  results maybe different.

    But it is not a big problem. I think.

    Regards...