gpt4 book ai didi

c - sprintf float 和 double 变量

转载 作者:太空宇宙 更新时间:2023-11-04 06:38:05 24 4
gpt4 key购买 nike

sprintf(SBuff,"Float value %0.4f ",temp_float);
USART0_TransmitString(SBuff);

我也尝试过 %f,并将 temp_float 变量设为双倍 (%lf)。

但在 Usart 上,我总是得到 Float value ? 代替 temp_float 值,我得到问号。

最佳答案

AVR 的 sprintf() 默认不实现浮点来节省闪存空间,您需要更改一些编译器选项才能实现;

If the full functionality including the floating point conversions is required, the following options should be used:

-Wl,-u,vfprintf -lprintf_flt -lm

可以找到完整的详细信息 here .

关于c - sprintf float 和 double 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12330499/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com