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.

[参考译文] CCS/EVM430-FR6047:浮点值舍入

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

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/924931/ccs-evm430-fr6047-rounding-off-of-float-values

器件型号:EVM430-FR6047

工具/软件:Code Composer Studio

您好!

当我使用 sprintf 评估大浮点值并通过 UART 发送时、会观察到舍入。 为什么会发生这种情况? 如何避免这种情况? 小于10000000的值、使用此加法即可正常工作。

float check = 10000000;
check = check + 1.5;

len = strlen (stringTemp);
sprintf (stringTemp、"%15.3f"、check);

for (i=0;<len; i++){ while(!(UCA0IFG&UCTXIFG)); UCA0TXBUF = stringTemp[i]; }


此致、

Prudhvi Sagar  

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

    您已超过了类型 float 可用的精度。  值 10000002是最接近10000001.5的值、类型 float 可以表示该值。  请考虑更改为 双精度型。

    谢谢、此致、

    乔治