6,BCD转十进制uint8_t BCDToInt(uint8_t bcd) //BCD转十进制
{
return ((0xff & (bcd>>4))*10 +(0xf & bcd));
}
static int int2string(long lNum,char chWord[])
{
int i=0,j;
char chTemp;
if(lNum == 0)
{
chWord = '0' ;
i++;
}
else
{
while(lNum!=0)/*依次取整数的末位,存入chWord */
{
chWord = '0' +lNum%10;/*转换为数字的ASCII码*/
i++;
lNum = lNum/10;
}
//chWord = '\0'; /*字符串最后一位加'\0'*/
for(j=0;j<i/2;j++)/*将字符串转置*/
{
chTemp = chWord[j];
chWord[j] = chWord[i-1-j];
chWord[i-1-j] = chTemp;
}
}
return i;
}
|