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:CLAmath-Library 中的 cla_floor 和 cla_ceil 函数存在错误?

Guru**** 2689775 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1597934/c2000ware-bug-in-cla_floor-and-cla_ceil-functions-in-clamath-library

器件型号: C2000WARE

您好!

我对 CLAmath 库中的 cla_floor 和 cla_ceil 函数有疑问。 其定义如下:

//
// 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);
}

我希望对正数和负数都使用该函数。 但是、对于负数、由于转换为 uint32_t、结果似乎是不稳定的 这里不应该使用 int32_t? 还是我遗漏了什么? 提前感谢您!