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.

[参考译文] TMS320F28P650DK:浮点数精度损耗

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

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1524995/tms320f28p650dk-float-number-precision-loss

器件型号:TMS320F28P650DK

工具/软件:

您好、

  在我的工程中、我将无符号整数转换为浮点值、因为用于算法计算。

uint32t 值= 30;

将系数0.01f 相乘时、预期值应该是

float value1 =(float32_t) value * (0.01f)= 0.30f

但我得到的响应值为0.29999981

您能告诉我在工程设置配置中缺少哪些设置吗  

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

    尊敬的 Naveen:

    您可以尝试将浮点模式调整为宽松、并查看这是否有任何差异。 此处的网站是确定代码中任何十进制数的浮点近似值的良好参考  https://www.h-schmidt.net/FloatConverter/IEEE754.html

    此致、

    彼得

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

    您好、Peter:

     我已将其设置为 RELAX 模式,启用了--fp_single_precision_constant 和 rts2800_fpu32_eabi.lib =>项目属性中的运行时支持库,而不是自动。  

    因此,更改后,我使用 roundf(float x)通过包括 math.h 头文件取整结果,我得到了结果。

    问题已像现在一样得到解决