请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号: 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? 还是我遗漏了什么? 提前感谢您!