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.

floating point value in CLA task

Other Parts Discussed in Thread: TEST2

I'm testing CLA task, the floating values in the task are very strange.
following source, the result  must be test1=1, test2=2 and test3=3, but test1=1.1.
it can say that test1 is not increasing with step 0.1 (maybe 0.0999999).
I don't know the reason.
plz let me know it.

============ Program =================================

//  Cla1Task1 is triggered by  EPWM1_INT

 

#pragma DATA_SECTION(test1,"Cla1ToCpuMsgRAM");
volatile float test1;

#pragma DATA_SECTION(test2,"Cla1ToCpuMsgRAM");
volatile float test2;

#pragma DATA_SECTION(test3,"Cla1ToCpuMsgRAM");
volatile float test3;

interrupt void Cla1Task1 ( void )
{
    _mdebugstop();

    if (test1 < 1)
    {
      test1 = test1 + 0.1;
      test2 = test2 + 0.2;
      test3 = test1 + test2;
    }

}

// first, test1, test2, test3 initialization
interrupt void Cla1Task8 ( void )
{
 test1 = 0;
 test2 = 0;
 test3 = 0;
}


========== result ==================================

Expression    Type    Value                      Address
test1                float     1.1                 0x00001480@Data 
test2                float     2.2                 0x00001482@Data 
test3                float     3.299999     0x00001484@Data