if statement involves float prompt error :MISRA C 2012 R13.5

107 Views Asked by At

This is my first time asking a question, and my English is not good! When a Floating-point arithmetic number (size comparison) appears in my if statement, an error is reported that triggers MISRA R13.5. This is my code section:

static float32_t g_A_pf[4]={0.1f};
static float32_t g_A_f = 0.00001f;
static float32_t g_B_f = 0.1f;
static float32_t g_C_f = 0.1f;
static float32_t g_D_f = 0.1f;
        /* Float */
    if( ( g_A_pf[0]  > g_A_pf[1]  ) && (g_A_pf[2]  < g_A_pf[3]  ) )
        {
                ;/* MISRA 2012 Rule 13.5: right hand operand of && or || operator may not contain side effects  */
        }

    if( ( g_A_f   > g_B_f   ) && (g_C_f   < g_D_f   ) )
        {
                ;/* MISRA 2012 Rule 13.5: right hand operand of && or || operator may not contain side effects  */
        }

    if( ( t_A_f   > t_B_f   ) && (t_C_f   < t_D_f   ) )
        {
                ;/* MISRA 2012 Rule 13.5: right hand operand of && or || operator may not contain side effects  */
    }
0

There are 0 best solutions below