guchq 发表于 2008-1-12 14:30:09

icc avr中的char *ftoa(float f, int *status)函数如何使用?

我想把由AD转化得来的温度值显示在18b20上,但要求只截取小数点后两位,用上述函数怎么完成;能不能有个例程?或者有其他的方法完成,我发现如果用传统的方法:就是把每位的数字分开显示有点麻烦;请马老师指教!

machao 发表于 2008-1-12 23:56:03

传统的方法你掌握了吗?先掌握传统的方法,把基础打好.

guchq 发表于 2008-1-14 09:39:32

改错:把由AD转化得来的温度值显示在lcd上
不好意思第一次发帖!
如果是将每位数字分开显示的话已经可以显示的:用显示几位就乘以10的几次幂,在将其一位一位显示出来

machao 发表于 2008-1-14 10:26:19

char *ftoa(float f, int *status)

converts a floating point number to the ASCII representation. It returns a static buffer of approximately 15 chars. If the input is out of range, *status is set to the constant _FTOA_TOO_LARGE, or _FTOA_TOO_SMALL, defined in stdlib.h, and 0 is returned. Otherwise, *status is set to 0 and the char buffer is returned. This version of the ftoa is fast but cannot handle values outside of the range listed. Please contact us if you need a (much) larger version that handles greater ranges.
页: [1]
查看完整版本: icc avr中的char *ftoa(float f, int *status)函数如何使用?