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.

Behaviour of power function

Other Parts Discussed in Thread: TMS320F28377D

Hi All,

I am using TMS320F28377D for my inverter application. In my software i have to use power function. Which is defined under math.h as "double pow(double x, double y);".

I have noticed strange behaviour of pow function. For Example,

pow(2,14) returenes = 16384. (OK that is fine)

But, pow(2,15) returenes = 32767.98 instead of 32768.

I can not accept this minor change please suggest any solution. I have captured image as i observed and that is attached herewith.

Thanks and Regards,

Maulik

 


  • Amtech said:
    I can not accept this minor change please suggest any solution. I have captured image as i observed and that is attached herewith.

    I haven't investigated the accuracy of the floating point pow() function, but notice that your code raises 2 to an integer power.

    In which case, the example could instead use a shift. e.g.:

        temp_bit = 1 << j;
        temp_bit = ~temp_bit;

    Is an integer shift suitable for your program?