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.

C2000WARE: Bug in CLA_floor and CLA_ceil functions in CLAmath-Library?

Part Number: C2000WARE

Hi!

I have a question about the CLA_floor and CLA_ceil functions in the CLAmath library. They are defined as follows:

//
// CLA_floor(float32_t val)
//
static inline float32_t CLA_floor(float32_t val)
{
    volatile uint32_t temp = (uint32_t)val;

    if(val < 0.0f)
    {
        temp = temp - 1;
    }

    return((float32_t)temp);
}

//
// CLA_ceil(float32_val)
//
static inline float32_t CLA_ceil(float32_t val)
{
    volatile uint32_t temp = (uint32_t)val;

    if(val > 0.0f)
    {
        temp = temp + 1;
    }

    return((float32_t)temp);
}

I would like to use the function for both positive and negative numbers. However, for negative numbers, the result seems to be erratic, due to the cast to uint32_t. Shouldn't a int32_t be used here instead? Or am I missing anything? Thank you in advance!