int Int2BCD(int Value, int ValueDigit, char* BCD)
{
char tmp[10]={"\0"};
int i,j,Result=0;
for(i=0;ValueDigit>0;Value /= 100,i++,ValueDigit-=2)
{
Result = Value % 100;
tmp[i] = (char)((( Result/10 )<<4) | (Result%10));
}
for(j=0,i=i-1;i>=0;i--,j++)
BCD[j] = tmp[i];
BCD[j] = '\0';
return j;
}
BCD碼原理參照:
http://www.cublog.cn/opera/showart.php?blogid=15478&id=83640
http://xxcom.blogchina.com/
沒有留言:
張貼留言