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.

AWR1642: compiler code optimization issue

Part Number: AWR1642

Hello team,

Customer is using optimization level is L3. During the test, The found some calculation can not get a correct result shown below, but when he add 'f' after the '2.0', the result become correct. Sometimes, they need to add a type conversion to float, then the calculation get correct result. Can you please explain how to avoid this bug, and how the complier optimize the code?

example 1, add 'f' after the '2.0' works.

float invOneQFormat = 1.0 / (1U << xyzOutputQFormat);
struct radar {float power;...};

radar.power = 6 * ( (float)detObj2D[ii].peakVal*( invOneQFormat/2.0) );// The result always equals to 0

radar.power = 6 * ( (float)detObj2D[ii].peakVal*( invOneQFormat/2.0f) );// The result is correct

example 2. add 'f' after the '3.14' doesn't work, only add type conversion to float works.

float angleRad, angleDeg;
angleRad = angleDeg * (3.14f/180.0f);// The result always equals to 0
angleRad = angleDeg * (float)(3.14f/180.0f);// The result is correct

Thanks, 

Wesley