< language=Java1.1>
write(overlap1);
>
很多人都说用定义共同体的方式将float数据转换成4个char型数据,于是我依葫芦画瓢了以下代码:
union Floattochar{
float f;
char u[4];
};
float time = 10.0/250.0;
char cha;
char chb;
char chc;
char chd;
union Floattochar sc;
sc.f = time;
cha = sc.u[0];
chb = sc.u[1];
chc = sc.u[2];
chd = sc.u[3];
Serial_SendChar(cha);
Serial_SendChar(chb);
Serial_SendChar(chc);
Serial_SendChar(chd);